Feature keep file 1135 (#1139)
* Added gitignorefile * Fixed gitignorefile for os.PathLike paths * --keep now follows .gitignore rules * Fixed ruff QA error * Added support for .osxphotos_keep file * Added reference to .osxphotos_keep * Added tests for .osxphotos_keep * Updated help text for --cleanup, --keep
This commit is contained in:
38
tests/test_gitignorefile_ignored.py
Normal file
38
tests/test_gitignorefile_ignored.py
Normal file
@@ -0,0 +1,38 @@
|
||||
import os
|
||||
import unittest
|
||||
|
||||
import osxphotos.gitignorefile
|
||||
|
||||
|
||||
class TestIgnored(unittest.TestCase):
|
||||
def test_simple(self):
|
||||
for is_dir in (None, False, True):
|
||||
with self.subTest(i=is_dir):
|
||||
self.assertFalse(
|
||||
osxphotos.gitignorefile.ignored(__file__, is_dir=is_dir)
|
||||
)
|
||||
if is_dir is not True:
|
||||
self.assertTrue(
|
||||
osxphotos.gitignorefile.ignored(
|
||||
f"{os.path.dirname(__file__)}/__pycache__/some.pyc",
|
||||
is_dir=is_dir,
|
||||
)
|
||||
)
|
||||
self.assertFalse(
|
||||
osxphotos.gitignorefile.ignored(
|
||||
os.path.dirname(__file__), is_dir=is_dir
|
||||
)
|
||||
)
|
||||
if is_dir is not False:
|
||||
self.assertTrue(
|
||||
osxphotos.gitignorefile.ignored(
|
||||
f"{os.path.dirname(__file__)}/__pycache__", is_dir=is_dir
|
||||
)
|
||||
)
|
||||
else:
|
||||
# Note: this test will fail if your .gitignore file does not contain __pycache__/
|
||||
self.assertFalse(
|
||||
osxphotos.gitignorefile.ignored(
|
||||
f"{os.path.dirname(__file__)}/__pycache__", is_dir=is_dir
|
||||
)
|
||||
)
|
||||
Reference in New Issue
Block a user