@@ -27,16 +27,6 @@ def pytest_configure(config: pytest.Config) -> None:
27
27
os .environ ["SOURCE_DATE_EPOCH" ] = "1234567890"
28
28
os .environ ["SETUPTOOLS_SCM_DEBUG" ] = "1"
29
29
30
- # Register custom markers
31
- config .addinivalue_line (
32
- "markers" ,
33
- "git: mark test to use git SCM" ,
34
- )
35
- config .addinivalue_line (
36
- "markers" ,
37
- "hg: mark test to use mercurial SCM" ,
38
- )
39
-
40
30
41
31
VERSION_PKGS = ["setuptools" , "setuptools_scm" , "packaging" , "build" , "wheel" ]
42
32
@@ -99,48 +89,30 @@ def debug_mode() -> Iterator[DebugMode]:
99
89
100
90
101
91
def setup_git_wd (wd : WorkDir , monkeypatch : pytest .MonkeyPatch | None = None ) -> WorkDir :
102
- """Set up a WorkDir with git initialized and configured for testing."""
103
- if monkeypatch :
104
- monkeypatch .delenv ("HOME" , raising = False )
105
- wd ("git init" )
106
- wd (
"git config user.email [email protected] " )
107
- wd ('git config user.name "a test"' )
108
- wd .add_command = "git add ."
109
- wd .commit_command = "git commit -m test-{reason}"
110
- wd .tag_command = "git tag {tag}"
111
- return wd
92
+ """Set up a WorkDir with git initialized and configured for testing.
93
+
94
+ Note: This is a compatibility wrapper. Consider using wd.setup_git() directly.
95
+ """
96
+ return wd .setup_git (monkeypatch )
112
97
113
98
114
99
def setup_hg_wd (wd : WorkDir ) -> WorkDir :
115
- """Set up a WorkDir with mercurial initialized and configured for testing."""
116
- wd ("hg init" )
117
- wd .add_command = "hg add ."
118
- wd .commit_command = 'hg commit -m test-{reason} -u test -d "0 0"'
119
- wd .tag_command = "hg tag {tag}"
120
- return wd
100
+ """Set up a WorkDir with mercurial initialized and configured for testing.
101
+
102
+ Note: This is a compatibility wrapper. Consider using wd.setup_hg() directly.
103
+ """
104
+ return wd .setup_hg ()
121
105
122
106
123
107
@pytest .fixture
124
- def wd (
125
- tmp_path : Path , request : pytest .FixtureRequest , monkeypatch : pytest .MonkeyPatch
126
- ) -> WorkDir :
127
- """WorkDir fixture that automatically configures SCM based on markers."""
108
+ def wd (tmp_path : Path ) -> WorkDir :
109
+ """Base WorkDir fixture that returns an unconfigured working directory.
110
+
111
+ Individual test modules should override this fixture to set up specific SCM configurations.
112
+ """
128
113
target_wd = tmp_path .resolve () / "wd"
129
114
target_wd .mkdir ()
130
- wd = WorkDir (target_wd )
131
-
132
- # Check for SCM markers on the test function or module
133
- git_marker = request .node .get_closest_marker ("git" )
134
- hg_marker = request .node .get_closest_marker ("hg" )
135
-
136
- # Configure SCM based on markers
137
- if git_marker :
138
- setup_git_wd (wd , monkeypatch )
139
- elif hg_marker :
140
- setup_hg_wd (wd )
141
- # If no SCM markers, return unconfigured workdir
142
-
143
- return wd
115
+ return WorkDir (target_wd )
144
116
145
117
146
118
@pytest .fixture (scope = "session" )
0 commit comments