MCPcopy Create free account
hub / github.com/dot-agent/nextpy / test_initialize_non_existent_gitignore

Function test_initialize_non_existent_gitignore

tests/utils/test_utils.py:281–309  ·  view source on GitHub ↗

Test that the generated .gitignore_file file on nextpy init contains the correct file names with correct formatting. Args: tmp_path: The root test path. mocker: The mock object. gitignore_exists: Whether a gitignore file exists in the root dir.

(tmp_path, mocker, gitignore_exists)

Source from the content-addressed store, hash-verified

279
280@pytest.mark.parametrize("gitignore_exists", [True, False])
281def test_initialize_non_existent_gitignore(tmp_path, mocker, gitignore_exists):
282 """Test that the generated .gitignore_file file on nextpy init contains the correct file
283 names with correct formatting.
284
285 Args:
286 tmp_path: The root test path.
287 mocker: The mock object.
288 gitignore_exists: Whether a gitignore file exists in the root dir.
289 """
290 expected = constants.GitIgnore.DEFAULTS.copy()
291 mocker.patch("nextpy.constants.GitIgnore.FILE", tmp_path / ".gitignore")
292
293 gitignore_file = tmp_path / ".gitignore"
294
295 if gitignore_exists:
296 gitignore_file.touch()
297 gitignore_file.write_text(
298 """*.db
299 __pycache__/
300 """
301 )
302
303 prerequisites.initialize_gitignore()
304
305 assert gitignore_file.exists()
306 file_content = [
307 line.strip() for line in gitignore_file.open().read().splitlines() if line
308 ]
309 assert set(file_content) - expected == set()
310
311
312def test_app_default_name(tmp_path, mocker):

Callers

nothing calls this directly

Calls 4

setFunction · 0.85
readMethod · 0.80
copyMethod · 0.45
patchMethod · 0.45

Tested by

no test coverage detected