cdent / gabbi

Declarative HTTP Testing for Python and anything else
http://gabbi.readthedocs.org/
Other
148 stars 34 forks source link

Unit tests fail with PyYAML 5.1b3 #266

Closed amoralej closed 5 years ago

amoralej commented 5 years ago

While testing gabbi with updated pyyaml, it fails to discover unit tests in:

Failures during discovery

`b'--- import errors ---\nFailed to call load_tests:\nTraceback (most recent call last):\n File "/home/amoralej/tmp/python-gabbi/gabbi-1.44.0/.tox/py37/lib/python3.7/site-packages/unittest2/loader.py", line 147, in loadTestsFromModule\n return load_tests(self, tests, pattern)\n File "/home/amoralej/tmp/python-gabbi/gabbi-1.44.0/gabbi/tests/test_unsafe_yaml.py", line 49, in load_tests\n **BUILD_TEST_ARGS)\n File "/home/amoralej/tmp/python-gabbi/gabbi-1.44.0/gabbi/driver.py", line 118, in build_tests\n safe=safe_yaml)\n File "/home/amoralej/tmp/python-gabbi/gabbi-1.44.0/gabbi/utils.py", line 111, in load_yaml\n return load(source.read())\n File "/home/amoralej/tmp/python-gabbi/gabbi-1.44.0/.tox/py37/lib/python3.7/site-packages/yaml/init.py", line 113, in load\n return loader.get_single_data()\n File "/home/amoralej/tmp/python-gabbi/gabbi-1.44.0/.tox/py37/lib/python3.7/site-packages/yaml/constructor.py", line 43, in get_single_data\n return self.construct_document(node)\n File "/home/amoralej/tmp/python-gabbi/gabbi-1.44.0/.tox/py37/lib/python3.7/site-packages/yaml/constructor.py", line 52, in construct_document\n for dummy in generator:\n File "/home/amoralej/tmp/python-gabbi/gabbi-1.44.0/.tox/py37/lib/python3.7/site-packages/yaml/constructor.py", line 404, in construct_yaml_map\n value = self.construct_mapping(node)\n File "/home/amoralej/tmp/python-gabbi/gabbi-1.44.0/.tox/py37/lib/python3.7/site-packages/yaml/constructor.py", line 210, in construct_mapping\n return super().construct_mapping(node, deep=deep)\n File "/home/amoralej/tmp/python-gabbi/gabbi-1.44.0/.tox/py37/lib/python3.7/site-packages/yaml/constructor.py", line 135, in construct_mapping\n value = self.construct_object(value_node, deep=deep)\n File "/home/amoralej/tmp/python-gabbi/gabbi-1.44.0/.tox/py37/lib/python3.7/site-packages/yaml/constructor.py", line 92, in construct_object\n data = constructor(self, node)\n File "/home/amoralej/tmp/python-gabbi/gabbi-1.44.0/.tox/py37/lib/python3.7/site-packages/yaml/constructor.py", line 420, in construct_undefined\n node.start_mark)\nyaml.constructor.ConstructorError: could not determine a constructor for the tag \'!NanChecker\'\n in "", line 8, column 16:\n $.nan: !NanChecker {}\n ^\n'

Note that, although PyYAML is capped in requirements.txt, it's a problem when using it in a distro, as Fedora where PyYAML-5.1b3 has been added.

Root cause for this issue seems to be https://github.com/yaml/pyyaml/commit/33644a0ec61231a835481a669518f4a6ccd61c64 which has introduced changes in yaml loading.

cdent commented 5 years ago

Thanks for the report. Was expecting this because there was a similar issue when the aborted 4.x versions came out.

The tests for NanChecker stuff were always a bit weird. I think it came about from something @sileht was doing.

If you have some ideas on how to fix it, please say so and submit a patch, otherwise I'll dig into it next week.

cdent commented 5 years ago

@amoralej and @sileht could you look at/try #267 and let me know if it is okay? thanks.