clembou/behave-pandas

Exception for new version of pandas

username-still-not-available opened this issue · 3 comments

I really would like to use your testing tool, but once I run testing example, it raise an Exception. I think, there is probably incompatibility between python and pandas versions.

Python 3.6.5 (default, Apr 25 2018, 14:23:58) 
[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
import pandas as pd
pd.__version__
'0.20.2'

What is you opinion?

Feature: Table printer # select.feature:1
  as a tester
  I want to be able to create gherkin tables from existing data frames
  Scenario: simple index                                                             # select.feature:6
    Given a gherkin table as input                                                   # steps/steps.py:9 0.001s
      | str       | float     | str                 |
      | index_col | float_col | str_col             |
      | egg       | 3.0       | silly walks         |
      | spam      | 4.1       | spanish inquisition |
      | bacon     | 5.2       | dead parrot         |
    When converted to a data frame using 1 row as column names and 1 column as index # steps/steps.py:14 0.010s
    And printed using data_frame_to_table                                            # steps/steps.py:24 0.011s
      Traceback (most recent call last):
        File "/usr/local/lib/python3.6/site-packages/behave/model.py", line 1329, in run
          match.run(runner.context)
        File "/usr/local/lib/python3.6/site-packages/behave/matchers.py", line 98, in run
          self.func(context, *args, **kwargs)
        File "steps/steps.py", line 26, in step_impl
          context.result = dataframe_to_table(context.parsed)
        File "/usr/local/lib/python3.6/site-packages/behave_pandas/printer.py", line 14, in dataframe_to_table
          cols_with_potential_nones = to_format.select_dtypes('object').columns
        File "/usr/local/lib/python3.6/site-packages/pandas/core/frame.py", line 2259, in select_dtypes
          raise TypeError('include and exclude must both be non-string'
      TypeError: include and exclude must both be non-string sequences

    Then it prints a valid string copy pasteable into gherkin files                  # None
      """
      | object    | float64   | object              |
      | index_col | float_col | str_col             |
      | egg       | 3.0       | silly walks         |
      | spam      | 4.1       | spanish inquisition |
      | bacon     | 5.2       | dead parrot         |
      """


Failing scenarios:
  select.feature:6  simple index

0 features passed, 1 failed, 0 skipped
0 scenarios passed, 1 failed, 0 skipped
2 steps passed, 1 failed, 1 skipped, 0 undefined
Took 0m0.022s

It is working with latest pandas: 0.22.0.
I will keep my issue for documentation purpose.

Thanks for your report! This library is pretty new, so I only tested it under what my project is actually using (we are on 0.22.0), and focusing on the dtypes we need. You may hit a few more snags on the way - please report them if you do (even better with a PR 😄 ).

In this case it looks like you were able to upgrade to the latest pandas so all is well!

Thanks for reply :-) I am using it currently and everything working now. Once I found an improvement I definitely write you. Your tool satisfy our purpose for now :-)