-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
django.test.TestCase
not recorded when the tests are run by pytest
#363
Comments
@dustinbyrne can you provide more information to help Navie spec this issue? Then apply the label |
Title: Ensure Problem: Analysis: Proposed Changes:
@pytest.hookimpl
def pytest_runtest_call(item):
# The presence of a `_testcase` attribute on an item indicates
# that it was created from a `unittest.TestCase` or `django.test.TestCase`
if hasattr(item, "_testcase") or (hasattr(item.obj, "__class__") and
issubclass(item.obj.__class__, django.test.TestCase)):
setattr(
item._testcase,
"_appmap_pytest_recording",
True,
)
if not noappmap.disables(item.obj, item.cls):
testing_framework.disable_test_case(item.obj)
item.obj = recorded_testcase(item)(item.obj)
class TestDjangoTestCaseRunner(_TestTestRunner):
@classmethod
def setup_class(cls):
cls._test_type = "pytest"
def run_tests(self, testdir):
testdir.test_type = "pytest"
result = testdir.runpytest("-svv")
result.assert_outcomes(passed=1)
def test_enabled(self, testdir):
self.run_tests(testdir)
assert len(list(testdir.output().iterdir())) == 1
verify_expected_appmap(testdir)
verify_expected_metadata(testdir)
[pytest]
DJANGO_SETTINGS_MODULE = djangoapp.settings By ensuring that both I'm confident that these changes will address the recording issue for |
paperless uses pytest to run Django tests. This isn't a usual configuration for a django project. The pytest plugin provided by |
@apotterri correction from Kevin: Please edit Dustin's issue above and it will kick off again and you can see if it is more correctly scoped. This would be a great issue to discuss tomorrow at standup if you could scope the issue and rerun the plan. The issue was not correctly specified by Dustin, since it was listed as a "bug" when it is really an enhancement to support this configuration. So let's improve the issue and see what comes afterward. |
This states that Django uses unittest, so shouldn't that work? Is the issue that the import is |
django.test.TestCase
not recorded
django.test.TestCase
not recordeddjango.test.TestCase
not recorded by pytest
django.test.TestCase
not recorded by pytestdjango.test.TestCase
not recorded when the tests are run by pytest
paperless-ngx
usesdjango.test.TestCase
for its tests.django.test.TestCase
is a subclass ofunittest.TestCase
that adds functionality for testing Django applications.When running these test cases with
appmap-python
, no AppMaps are emitted. It seems as though the subclasses ofdjango.test.TestCase
are not treated equally to those ofunittest.TestCase
.The text was updated successfully, but these errors were encountered: