Skip to content

Commit 8b13307

Browse files
committed
Refactoring
1 parent 13d8b38 commit 8b13307

File tree

5 files changed

+15
-11
lines changed

5 files changed

+15
-11
lines changed

examples/fixtures/test_fixture_setup/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@
2626

2727

2828
@pytest.fixture
29-
def fixture_setup_config():
29+
def test_fixture_setup_config():
3030
logging.error(LOG_MESSAGE_SETUP)
3131
return mock.Mock()

examples/fixtures/test_fixture_setup/test_fixture_setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@
2525
# limitations under the License.
2626

2727

28-
def test_fixture_setup(fixture_setup_config):
29-
assert fixture_setup_config is not None
28+
def test_fixture_setup(test_fixture_setup_config):
29+
assert test_fixture_setup_config is not None

examples/fixtures/test_fixture_teardown/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828

2929
@pytest.fixture
30-
def fixture_teardown_config():
30+
def test_fixture_teardown_config():
3131
logging.error(LOG_MESSAGE_BEFORE_YIELD)
3232
yield mock.Mock()
3333
logging.error(LOG_MESSAGE_TEARDOWN)

examples/fixtures/test_fixture_teardown/test_fixture_teardown.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@
2727
from time import sleep
2828

2929

30-
def test_fixture_teardown(fixture_teardown_config):
30+
def test_fixture_teardown(test_fixture_teardown_config):
3131
sleep(0.001)
32-
assert fixture_teardown_config is not None
32+
assert test_fixture_teardown_config is not None

tests/integration/test_fixtures.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ def test_fixture_setup(mock_client_init):
8585

8686
variables = dict(utils.DEFAULT_VARIABLES)
8787
variables['rp_report_fixtures'] = True
88+
test_path = 'examples/fixtures/test_fixture_setup'
8889
result = utils.run_pytest_tests(tests=['examples/fixtures/test_fixture_setup'], variables=variables)
8990
assert int(result) == 0, 'Exit code should be 0 (no errors)'
9091

@@ -94,14 +95,15 @@ def test_fixture_setup(mock_client_init):
9495

9596
call_args = mock_client.start_test_item.call_args_list
9697
setup_call_args = call_args[1][0]
97-
step_name = 'function fixture setup: fixture_setup_config'
98+
fixture_name = f'{test_path.split("/")[-1]}_config'
99+
step_name = f'function fixture setup: {fixture_name}'
98100
assert setup_call_args[0] == step_name
99101

100102
setup_call_kwargs = call_args[1][1]
101103
assert not setup_call_kwargs['has_stats']
102104

103105
teardown_call_args = call_args[-1][0]
104-
assert teardown_call_args[0] == 'function fixture teardown: fixture_setup_config'
106+
assert teardown_call_args[0] == f'function fixture teardown: {fixture_name}'
105107

106108
setup_call_kwargs = call_args[-1][1]
107109
assert not setup_call_kwargs['has_stats']
@@ -128,7 +130,8 @@ def test_fixture_teardown(mock_client_init):
128130

129131
variables = dict(utils.DEFAULT_VARIABLES)
130132
variables['rp_report_fixtures'] = True
131-
result = utils.run_pytest_tests(tests=['examples/fixtures/test_fixture_teardown'], variables=variables)
133+
test_path = 'examples/fixtures/test_fixture_teardown'
134+
result = utils.run_pytest_tests(tests=[test_path], variables=variables)
132135
assert int(result) == 0, 'Exit code should be 0 (no errors)'
133136

134137
start_count = mock_client.start_test_item.call_count
@@ -137,14 +140,15 @@ def test_fixture_teardown(mock_client_init):
137140

138141
call_args = mock_client.start_test_item.call_args_list
139142
setup_call_args = call_args[1][0]
140-
setup_step_name = 'function fixture setup: fixture_teardown_config'
143+
fixture_name = f'{test_path.split("/")[-1]}_config'
144+
setup_step_name = f'function fixture setup: {fixture_name}'
141145
assert setup_call_args[0] == setup_step_name
142146

143147
setup_call_kwargs = call_args[1][1]
144148
assert not setup_call_kwargs['has_stats']
145149

146150
teardown_call_args = call_args[-1][0]
147-
teardown_step_name = 'function fixture teardown: fixture_teardown_config'
151+
teardown_step_name = f'function fixture teardown: {fixture_name}'
148152
assert teardown_call_args[0] == teardown_step_name
149153

150154
setup_call_kwargs = call_args[-1][1]

0 commit comments

Comments
 (0)