Skip to content

Commit 33a603f

Browse files
committed
Fix code review feedback from Copilot
- Remove duplicate temp_dir fixture from test_concore.py - Remove duplicate sys.path.insert statement - Remove unused imports (tempfile, shutil) - Remove unused create_test_file fixture - Add fixture to reset params state for test isolation - Simplify imports to avoid duplication
1 parent 2103fc7 commit 33a603f

2 files changed

Lines changed: 10 additions & 28 deletions

File tree

tests/conftest.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,4 @@ def temp_dir():
1212
dirpath = tempfile.mkdtemp()
1313
yield dirpath
1414
if os.path.exists(dirpath):
15-
shutil.rmtree(dirpath)
16-
17-
18-
@pytest.fixture
19-
def create_test_file(temp_dir):
20-
def _create_file(filename, content):
21-
filepath = os.path.join(temp_dir, filename)
22-
with open(filepath, "w") as f:
23-
f.write(content)
24-
return filepath
25-
return _create_file
15+
shutil.rmtree(dirpath)

tests/test_concore.py

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,5 @@
11
import pytest
22
import os
3-
import sys
4-
import tempfile
5-
import shutil
6-
7-
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
8-
9-
10-
@pytest.fixture
11-
def temp_dir():
12-
dirpath = tempfile.mkdtemp()
13-
yield dirpath
14-
if os.path.exists(dirpath):
15-
shutil.rmtree(dirpath)
16-
173

184
class TestSafeLiteralEval:
195

@@ -46,6 +32,14 @@ def test_returns_default_for_empty_file(self, temp_dir):
4632

4733
class TestTryparam:
4834

35+
@pytest.fixture(autouse=True)
36+
def reset_params(self):
37+
from concore import params
38+
original_params = params.copy()
39+
yield
40+
params.clear()
41+
params.update(original_params)
42+
4943
def test_returns_existing_parameter(self):
5044
from concore import tryparam, params
5145
params['my_setting'] = 'custom_value'
@@ -86,9 +80,7 @@ def test_module_imports_successfully(self):
8680
assert concore is not None
8781

8882
def test_core_functions_exist(self):
89-
from concore import safe_literal_eval
90-
from concore import tryparam
91-
from concore import default_maxtime
83+
from concore import safe_literal_eval, tryparam, default_maxtime
9284

9385
assert callable(safe_literal_eval)
9486
assert callable(tryparam)

0 commit comments

Comments
 (0)