* 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
39 lines
1.4 KiB
Python
39 lines
1.4 KiB
Python
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
|
|
)
|
|
)
|