Closed benkohler closed 1 year ago
This is caused by an incorrect decorator:
class TestEntropyInformation(unittest.TestCase):
""" Test cases for function `emit_passwords`. """
...
@staticmethod
def test_entropy_printout_valid_input(self):
values = self.run_xkcdpass_process('4', 'y')
self.assertIn('A 4 word password from this list will have roughly 51', values)
The staticmethod
decorator explicitly instructs that the function will not receive the instance as its first argument. The test_entropy_printout_valid_input
function expects to use that argument, so should not be decorated with staticmethod
.
Furthermore, this test requires that xkcdpass
be already installed, because it calls out to its executable. It would be better if it called the emit_password()
function directly.
Tests are passing for me on 1.19.4 now, thanks!
Tests fail on python-3.10: python3.10 -m pytest -vv -ra -l -Wdefault ====================================================================== test session starts ======================================================================= platform linux -- Python 3.10.0b4, pytest-6.2.4, py-1.10.0, pluggy-0.13.1 -- /usr/bin/python3.10 cachedir: .pytest_cache rootdir: /var/tmp/portage/app-admin/xkcdpass-1.19.2/work/xkcdpass-1.19.2 collecting ... collected 9 items
tests/test_xkcdpass.py::XkcdPasswordTests::test_acrostic PASSED [ 11%] tests/test_xkcdpass.py::XkcdPasswordTests::test_delim PASSED [ 22%] tests/test_xkcdpass.py::XkcdPasswordTests::test_loadwordfile PASSED [ 33%] tests/test_xkcdpass.py::XkcdPasswordTests::test_regex PASSED [ 44%] tests/test_xkcdpass.py::XkcdPasswordTests::test_set_case PASSED [ 55%] tests/test_xkcdpass.py::TestEmitPasswords::test_emits_no_separator_when_specified_separator_empty PASSED [ 66%] tests/test_xkcdpass.py::TestEmitPasswords::test_emits_specified_count_of_passwords PASSED [ 77%] tests/test_xkcdpass.py::TestEmitPasswords::test_emits_specified_separator_between_passwords PASSED [ 88%] tests/test_xkcdpass.py::TestEntropyInformation::test_entropy_printout_valid_input FAILED [100%]
============================================================================ FAILURES ============================================================================ ____ TestEntropyInformation.test_entropy_printout_valid_input ____
self = <unittest.case._Outcome object at 0x7f56c039e980>, test_case =
isTest = True
exc_info = None isTest = True old_success = True self = <unittest.case._Outcome object at 0x7f56c039e980> test_case =
/usr/lib/python3.10/unittest/case.py:59:
/usr/lib/python3.10/unittest/case.py:592: in run self._callTestMethod(testMethod) expecting_failure = False expecting_failure_class = False expecting_failure_method = False orig_result =
outcome = <unittest.case._Outcome object at 0x7f56c039e980>
result =
self =
testMethod = <staticmethod(<function TestEntropyInformation.test_entropy_printout_valid_input at 0x7f56c0399c60>)>
self =
method = <staticmethod(<function TestEntropyInformation.test_entropy_printout_valid_input at 0x7f56c0399c60>)>
method = <staticmethod(<function TestEntropyInformation.test_entropy_printout_valid_input at 0x7f56c0399c60>)> self =
/usr/lib/python3.10/unittest/case.py:549: TypeError ==================================================================== short test summary info ===================================================================== FAILED tests/test_xkcdpass.py::TestEntropyInformation::test_entropy_printout_valid_input - TypeError: TestEntropyInformation.test_entropy_printout_valid_input(... ================================================================== 1 failed, 8 passed in 0.37s ===================================================================
But tests pass on python-3.9: python3.9 -m pytest -vv -ra -l -Wdefault ====================================================================== test session starts ======================================================================= platform linux -- Python 3.9.6, pytest-6.2.4, py-1.10.0, pluggy-0.13.1 -- /usr/bin/python3.9 cachedir: .pytest_cache rootdir: /var/tmp/portage/app-admin/xkcdpass-1.19.2/work/xkcdpass-1.19.2 plugins: pkgcore-0.12.1 collecting ... collected 8 items
tests/test_xkcdpass.py::XkcdPasswordTests::test_acrostic PASSED [ 12%] tests/test_xkcdpass.py::XkcdPasswordTests::test_delim PASSED [ 25%] tests/test_xkcdpass.py::XkcdPasswordTests::test_loadwordfile PASSED [ 37%] tests/test_xkcdpass.py::XkcdPasswordTests::test_regex PASSED [ 50%] tests/test_xkcdpass.py::XkcdPasswordTests::test_set_case PASSED [ 62%] tests/test_xkcdpass.py::TestEmitPasswords::test_emits_no_separator_when_specified_separator_empty PASSED [ 75%] tests/test_xkcdpass.py::TestEmitPasswords::test_emits_specified_count_of_passwords PASSED [ 87%] tests/test_xkcdpass.py::TestEmitPasswords::test_emits_specified_separator_between_passwords PASSED [100%]
======================================================================= 8 passed in 0.34s ========================================================================