From b7e3057853ad47051839321191c1f975a78d9a29 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Thu, 3 Aug 2017 20:31:39 -0400 Subject: [PATCH] Fix tests, add tox.ini and travis.yml --- .gitignore | 4 +++- .travis.yml | 10 ++++++++++ setup.py | 1 + tests/__init__.py | 0 test_plat_other.py => tests/test_plat_other.py | 6 +++--- tox.ini | 11 +++++++++++ 6 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 .travis.yml create mode 100644 tests/__init__.py rename test_plat_other.py => tests/test_plat_other.py (98%) create mode 100644 tox.ini diff --git a/.gitignore b/.gitignore index 9074402..c544dbf 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,6 @@ *.egg-info /build /dist -.DS_Store \ No newline at end of file +.DS_Store +/.tox +__pycache__ diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..ae00db7 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,10 @@ +language: python +python: + - "2.7" + - "3.4" + - "3.5" + - "3.6" +install: + - "pip install tox" +script: + - "tox -e $(echo py$TRAVIS_PYTHON_VERSION | tr -d .)" diff --git a/setup.py b/setup.py index 65f2061..c473b7c 100644 --- a/setup.py +++ b/setup.py @@ -21,6 +21,7 @@ setup( author_email='hsoft@hardcoded.net', packages=['send2trash'], scripts=[], + test_suite='tests', url='https://github.com/hsoft/send2trash', license='BSD License', description='Send file to trash natively under Mac OS X, Windows and Linux.', diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/test_plat_other.py b/tests/test_plat_other.py similarity index 98% rename from test_plat_other.py rename to tests/test_plat_other.py index 9beaaf9..c4cd19a 100644 --- a/test_plat_other.py +++ b/tests/test_plat_other.py @@ -15,7 +15,7 @@ def touch(path): class TestHomeTrash(unittest.TestCase): def setUp(self): - self.file = NamedTemporaryFile(dir=op.expanduser("~"), + self.file = NamedTemporaryFile(dir=op.expanduser("~"), prefix='send2trash_test', delete=False) def test_trash(self): @@ -79,7 +79,7 @@ class TestTopdirTrash(TestExtVol): # then it gets renamed etc.) cfg = ConfigParser() cfg.read(op.join(self.trashDir, str(os.getuid()), 'info', self.fileName + '.trashinfo')) - self.assertEqual(self.fileName, cfg.get('Trash Info', 'Path', 1)) + self.assertEqual(self.fileName, cfg.get('Trash Info', 'Path', raw=True)) # Test .Trash-UID class TestTopdirTrashFallback(TestExtVol): @@ -112,7 +112,7 @@ class TestSymlink(TestExtVol): # Since is_parent uses realpath(), and our getdev uses is_parent, # this should work self.slDir = mktemp(prefix='s2t', dir=op.expanduser('~')) - + os.mkdir(op.join(self.trashTopdir, 'subdir'), 0o700) self.filePath = op.join(self.trashTopdir, 'subdir', self.fileName) touch(self.filePath) diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..ba8022c --- /dev/null +++ b/tox.ini @@ -0,0 +1,11 @@ +[tox] +envlist = py27,py34,py35,py36 +skip_missing_interpreters = True + +[testenv] +commands = + python setup.py test + +[testenv:py27] +deps = + configparser