Skip to content

Commit 00d6de6

Browse files
committed
Fix PT003 pytest-extraneous-scope-function
1 parent 465b822 commit 00d6de6

File tree

34 files changed

+61
-61
lines changed

34 files changed

+61
-61
lines changed

tests/agent_features/test_configuration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
SKIP_IF_NOT_PY311 = pytest.mark.skipif(sys.version_info < (3, 11), reason="TOML not in the standard library.")
4848

4949

50-
@pytest.fixture(scope="function")
50+
@pytest.fixture()
5151
def collector_available_fixture():
5252
# Disable fixture that requires real application to exist for this file
5353
pass

tests/agent_features/test_metric_normalization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def core_app(collector_agent_registration):
4040
return app._agent.application(app.name)
4141

4242

43-
@pytest.fixture(scope="function")
43+
@pytest.fixture()
4444
def rules_engine_fixture(core_app):
4545
rules_engine = core_app._rules_engine
4646
previous_rules = rules_engine["metric"]

tests/agent_features/test_serverless_mode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from newrelic.core.config import global_settings
2929

3030

31-
@pytest.fixture(scope="function")
31+
@pytest.fixture()
3232
def serverless_application(request):
3333
settings = global_settings()
3434
orig = settings.serverless_mode.enabled

tests/agent_streaming/conftest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def wait(self, *args, **kwargs):
6868
return super(SetEventOnWait, self).wait(*args, **kwargs)
6969

7070

71-
@pytest.fixture(scope="function")
71+
@pytest.fixture()
7272
def buffer_empty_event(monkeypatch):
7373
event = threading.Event()
7474

@@ -85,23 +85,23 @@ def batching(request):
8585
return request.param
8686

8787

88-
@pytest.fixture(scope="function")
88+
@pytest.fixture()
8989
def spans_received():
9090
from _test_handler import SPANS_RECEIVED
9191

9292
SPANS_RECEIVED.clear()
9393
return SPANS_RECEIVED
9494

9595

96-
@pytest.fixture(scope="function")
96+
@pytest.fixture()
9797
def span_batches_received():
9898
from _test_handler import SPAN_BATCHES_RECEIVED
9999

100100
SPAN_BATCHES_RECEIVED.clear()
101101
return SPAN_BATCHES_RECEIVED
102102

103103

104-
@pytest.fixture(scope="function")
104+
@pytest.fixture()
105105
def spans_processed_event():
106106
from _test_handler import SPANS_PROCESSED_EVENT
107107

tests/agent_streaming/test_stream_buffer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def stop_iteration_condition(*args, **kwargs):
2929
return StopIterationOnWait(*args, **kwargs)
3030

3131

32-
@pytest.fixture(scope="function")
32+
@pytest.fixture()
3333
def stop_iteration_on_wait(monkeypatch):
3434
monkeypatch.setattr(StreamBuffer, "condition", stop_iteration_condition)
3535

tests/agent_unittests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class FakeProtos:
4444
sys.modules["newrelic.core.infinite_tracing_pb2"] = FakeProtos
4545

4646

47-
@pytest.fixture(scope="function")
47+
@pytest.fixture()
4848
def global_settings(request, monkeypatch):
4949
ini_contents = request.getfixturevalue("ini")
5050

tests/agent_unittests/test_package_version_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
SKIP_IF_NOT_PY310_PLUS = pytest.mark.skipif(not IS_PY310_PLUS, reason="These features were added in 3.10+")
4242

4343

44-
@pytest.fixture(scope="function", autouse=True)
44+
@pytest.fixture(autouse=True)
4545
def patched_pytest_module(monkeypatch):
4646
for attr in VERSION_ATTRS:
4747
if hasattr(pytest, attr):
@@ -50,7 +50,7 @@ def patched_pytest_module(monkeypatch):
5050
yield pytest
5151

5252

53-
@pytest.fixture(scope="function", autouse=True)
53+
@pytest.fixture(autouse=True)
5454
def cleared_package_version_cache():
5555
"""Ensure cache is empty before every test to exercise code paths."""
5656
_get_package_version.cache_clear()

tests/agent_unittests/test_trace_cache.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class DummyTrace:
2525
pass
2626

2727

28-
@pytest.fixture(scope="function")
28+
@pytest.fixture()
2929
def trace_cache():
3030
return TraceCache()
3131

@@ -54,7 +54,7 @@ def test_trace_cache_methods(trace_cache):
5454
assert len(list(trace_cache.values())) == 1
5555

5656

57-
@pytest.fixture(scope="function")
57+
@pytest.fixture()
5858
def iterate_trace_cache(trace_cache):
5959
def _iterate_trace_cache(shutdown):
6060
while True:
@@ -70,7 +70,7 @@ def _iterate_trace_cache(shutdown):
7070
return _iterate_trace_cache
7171

7272

73-
@pytest.fixture(scope="function")
73+
@pytest.fixture()
7474
def change_weakref_dict_size(trace_cache):
7575
def _change_weakref_dict_size(shutdown, obj_refs):
7676
"""

tests/agent_unittests/test_wrappers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from newrelic.common.object_wrapper import function_wrapper
1818

1919

20-
@pytest.fixture(scope="function")
20+
@pytest.fixture()
2121
def wrapper():
2222
@function_wrapper
2323
def _wrapper(wrapped, instance, args, kwargs):
@@ -26,7 +26,7 @@ def _wrapper(wrapped, instance, args, kwargs):
2626
return _wrapper
2727

2828

29-
@pytest.fixture(scope="function")
29+
@pytest.fixture()
3030
def wrapped_function(wrapper):
3131
@wrapper
3232
def wrapped():

tests/cross_agent/fixtures/ecs_container_id/ecs_mock_server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,13 @@ def bad_response_get(self):
117117
self.wfile.write(response)
118118

119119

120-
@pytest.fixture(scope="function")
120+
@pytest.fixture()
121121
def mock_server():
122122
with MockExternalHTTPServer(handler=simple_get) as mock_server:
123123
yield mock_server
124124

125125

126-
@pytest.fixture(scope="function")
126+
@pytest.fixture()
127127
def bad_response_mock_server():
128128
with MockExternalHTTPServer(handler=bad_response_get) as bad_response_mock_server:
129129
yield bad_response_mock_server

0 commit comments

Comments
 (0)