betamaxpy / betamax

A VCR imitation designed only for python-requests.
https://betamax.readthedocs.io/en/latest/
Other
565 stars 62 forks source link

`test_records_new_interaction` fails #212

Open mtelka opened 1 month ago

mtelka commented 1 month ago
_________________ TestRecordOnce.test_records_new_interaction __________________

self = <tests.integration.test_record_modes.TestRecordOnce testMethod=test_records_new_interaction>

    def test_records_new_interaction(self):
        s = self.session
        with Betamax(s).use_cassette('test_record_once') as betamax:
            self.cassette_path = betamax.current_cassette.cassette_path
>           assert betamax.current_cassette.is_empty() is True
E           assert False is True
E            +  where False = <bound method Cassette.is_empty of <betamax.cassette.cassette.Cassette object at 0x7fffad73e340>>()
E            +    where <bound method Cassette.is_empty of <betamax.cassette.cassette.Cassette object at 0x7fffad73e340>> = <betamax.cassette.cassette.Cassette object at 0x7fffad73e340>.is_empty
E            +      where <betamax.cassette.cassette.Cassette object at 0x7fffad73e340> = <betamax.recorder.Betamax object at 0x7fffad73ef70>.current_cassette

tests/integration/test_record_modes.py:13: AssertionError
sigmavirus24 commented 1 month ago

This test does not fail for me or in CI

mtelka commented 1 month ago

Here are steps to reproduce:

$ wget https://github.com/betamaxpy/betamax/archive/refs/tags/0.9.0.tar.gz
$ gtar xf 0.9.0.tar.gz
$ cd betamax-0.9.0
$ tox -e py39
py39: install_deps> python -I -m pip install mock pytest 'requests>=2.0'
.pkg: install_requires> python -I -m pip install 'setuptools>=40.8.0' wheel
.pkg: _optional_hooks> python /usr/lib/python3.9/vendor-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
.pkg: get_requires_for_build_sdist> python /usr/lib/python3.9/vendor-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
.pkg: get_requires_for_build_wheel> python /usr/lib/python3.9/vendor-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
.pkg: install_requires_for_build_wheel> python -I -m pip install wheel
.pkg: prepare_metadata_for_build_wheel> python /usr/lib/python3.9/vendor-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
.pkg: build_sdist> python /usr/lib/python3.9/vendor-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
py39: install_package_deps> python -I -m pip install 'requests>=2.0'
py39: install_package> python -I -m pip install --force-reinstall --no-deps /tmp/test/betamax-0.9.0/.tox/.tmp/package/1/betamax-0.9.0.tar.gz
py39: commands[0]> py.test
...................F...............................................................................................................................                                                                                [100%]
================================================================================================================ FAILURES ================================================================================================================
______________________________________________________________________________________________ TestRecordOnce.test_records_new_interaction _______________________________________________________________________________________________

self = <tests.integration.test_record_modes.TestRecordOnce testMethod=test_records_new_interaction>

    def test_records_new_interaction(self):
        s = self.session
        with Betamax(s).use_cassette('test_record_once') as betamax:
            self.cassette_path = betamax.current_cassette.cassette_path
>           assert betamax.current_cassette.is_empty() is True
E           assert False is True
E            +  where False = <bound method Cassette.is_empty of <betamax.cassette.cassette.Cassette object at 0x7fffadbeba00>>()
E            +    where <bound method Cassette.is_empty of <betamax.cassette.cassette.Cassette object at 0x7fffadbeba00>> = <betamax.cassette.cassette.Cassette object at 0x7fffadbeba00>.is_empty
E            +      where <betamax.cassette.cassette.Cassette object at 0x7fffadbeba00> = <betamax.recorder.Betamax object at 0x7fffadb921f0>.current_cassette

tests/integration/test_record_modes.py:13: AssertionError
============================================================================================================ warnings summary ============================================================================================================
tests/integration/test_fixtures.py::TestPyTestParametrizedFixtures::test_pytest_fixture[https://httpbin.org/get]
tests/integration/test_fixtures.py::test_pytest_parametrize_with_filesystem_problematic_chars[aaa\\bbb]
tests/integration/test_fixtures.py::test_pytest_parametrize_with_filesystem_problematic_chars[ccc:ddd]
tests/integration/test_fixtures.py::test_pytest_parametrize_with_filesystem_problematic_chars[eee*fff]
  /tmp/test/betamax-0.9.0/.tox/py39/lib/python3.9/site-packages/betamax/fixtures/pytest.py:128: DeprecationWarning: betamax_parametrized_recorder and betamax_parametrized_session will be removed in betamax 1.0. Their behavior will be the default.
    warnings.warn(

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
======================================================================================================== short test summary info =========================================================================================================
FAILED tests/integration/test_record_modes.py::TestRecordOnce::test_records_new_interaction - assert False is True
1 failed, 146 passed, 4 warnings in 14.36s
py39: exit 1 (15.45 seconds) /tmp/test/betamax-0.9.0> py.test pid=10301
  py39: FAIL code 1 (35.56=setup[20.11]+cmd[15.45] seconds)
  evaluation failed :( (36.61 seconds)
$
mtelka commented 1 month ago

BTW, tested on both OpenIndiana and Rocky Linux 9.4 with same results.

sigmavirus24 commented 1 month ago

Can you ls tests/cassettes/ from within betamax-0.9.0?

mtelka commented 1 month ago
$ ls tests/cassettes/
 FakeBetamaxTestCase.test_fake.json
 GitHub_create_issue.json
 GitHub_emojis.json
 global_preserve_exact_body_bytes.json
 handles_digest_auth.json
 once_record_mode.json
 preserve_exact_bytes.json
 replay_interactions.json
 replay_multiple_times.json
 test.json
 test-multiple-cookies-regression.json
 test_record_once.json
 test_replays_response_on_right_order.json
 tests.integration.test_fixtures.TestPyTestFixtures.test_pytest_fixture.json
'tests.integration.test_fixtures.TestPyTestParametrizedFixtures.test_pytest_fixture[https---httpbin.org-get].json'
'tests.integration.test_fixtures.test_pytest_parametrize_with_filesystem_problematic_chars[aaa-bbb].json'
'tests.integration.test_fixtures.test_pytest_parametrize_with_filesystem_problematic_chars[ccc-ddd].json'
'tests.integration.test_fixtures.test_pytest_parametrize_with_filesystem_problematic_chars[eee-fff].json'
$
sigmavirus24 commented 1 month ago

Ah looks like this was fixed after 0.9.0 https://github.com/betamaxpy/betamax/commit/e3331c566fc02b2ef30e5480a71fd5a029cdf9c8 but needs a release