Skip to content

Commit 5811e44

Browse files
committed
refactor: clean up web framework tests
Only specify the need to rewrite assertions for _appmap.test.web_framework once. Improve lint score a bit, too.
1 parent fa786ce commit 5811e44

File tree

7 files changed

+15
-22
lines changed

7 files changed

+15
-22
lines changed

_appmap/importer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ def __new__(cls, scope, fn, static_fn):
5151
def fntype(self):
5252
if self.scope == Scope.MODULE:
5353
return FnType.MODULE
54-
else:
55-
return FnType.classify(self.static_fn)
54+
55+
return FnType.classify(self.static_fn)
5656

5757

5858
class Filter(ABC): # pylint: disable=too-few-public-methods

_appmap/metadata.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""Shared metadata gathering"""
22

33
import platform
4-
import re
54
from functools import lru_cache
65

76
from . import utils

_appmap/test/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import pytest
2+
3+
# Make sure assertions in web_framework get rewritten (e.g. to show
4+
# diffs in generated appmaps)
5+
pytest.register_assert_rewrite("_appmap.test.web_framework")

_appmap/test/test_configuration.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,39 +84,40 @@ def test_config_no_message(caplog):
8484
assert caplog.text == ""
8585

8686

87-
cf = lambda: ConfigFilter(NullFilter())
87+
def cf():
88+
return ConfigFilter(NullFilter())
8889

8990

9091
@pytest.mark.appmap_enabled(config="appmap-class.yml")
9192
def test_class_included():
92-
f = Filterable("package1.package2.Mod1Class", None)
93+
f = Filterable(None, "package1.package2.Mod1Class", None)
9394
assert cf().filter(f) is True
9495

9596

9697
@pytest.mark.appmap_enabled(config="appmap-func.yml")
9798
def test_function_included():
98-
f = Filterable("package1.package2.Mod1Class.func", None)
99+
f = Filterable(None, "package1.package2.Mod1Class.func", None)
99100
assert cf().filter(f) is True
100101

101102

102103
@pytest.mark.appmap_enabled(config="appmap-class.yml")
103104
def test_function_included_by_class():
104-
f = Filterable("package1.package2.Mod1Class.func", None)
105+
f = Filterable(None, "package1.package2.Mod1Class.func", None)
105106
assert cf().filter(f) is True
106107

107108

108109
@pytest.mark.appmap_enabled
109110
class TestConfiguration:
110111
def test_package_included(self):
111-
f = Filterable("package1.cls", None)
112+
f = Filterable(None, "package1.cls", None)
112113
assert cf().filter(f) is True
113114

114115
def test_function_included_by_package(self):
115-
f = Filterable("package1.package2.Mod1Class.func", None)
116+
f = Filterable(None, "package1.package2.Mod1Class.func", None)
116117
assert cf().filter(f) is True
117118

118119
def test_class_prefix_doesnt_match(self):
119-
f = Filterable("package1_prefix.cls", None)
120+
f = Filterable(None, "package1_prefix.cls", None)
120121
assert cf().filter(f) is False
121122

122123

_appmap/test/test_django.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@
2121
from _appmap.metadata import Metadata
2222

2323
from ..test.helpers import DictIncluding
24-
25-
# Make sure assertions in web_framework get rewritten (e.g. to show
26-
# diffs in generated appmaps)
27-
pytest.register_assert_rewrite("_appmap.test.web_framework")
28-
2924
# pylint: disable=unused-import,wrong-import-position
3025
from .web_framework import TestRemoteRecording # pyright:ignore
3126
from .web_framework import TestRequestCapture # pyright: ignore

_appmap/test/test_flask.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@
1313
from appmap.flask import AppmapFlask
1414

1515
from ..test.helpers import DictIncluding
16-
17-
# Make sure assertions in web_framework get rewritten (e.g. to show
18-
# diffs in generated appmaps)
19-
pytest.register_assert_rewrite("_appmap.test.web_framework")
20-
2116
# pylint: disable=unused-import,wrong-import-position
2217
from .web_framework import TestRemoteRecording # pyright:ignore
2318
from .web_framework import TestRequestCapture # pyright: ignore

appmap/flask.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
import re
33
import time
44

5-
import flask
6-
import flask.cli
75
import jinja2
86
from flask import g, got_request_exception, request, request_finished, request_started
97
from flask.cli import ScriptInfo

0 commit comments

Comments
 (0)