From 50d61b0e835d976b731442c7858b1e20a04edcce Mon Sep 17 00:00:00 2001 From: Edvinas Date: Thu, 12 Oct 2017 16:37:04 +0300 Subject: [PATCH] Add initial test, fix update travis config --- .travis.yml | 6 +++++- tests/example_test.py | 10 ---------- tests/test_utils.py | 27 +++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 11 deletions(-) delete mode 100644 tests/example_test.py create mode 100644 tests/test_utils.py diff --git a/.travis.yml b/.travis.yml index 41eba33..0a93303 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,8 +3,12 @@ python: - "3.5" install: - pip install -r requirements.txt + + # See https://gist.github.com/dan-blanchard/7045057 + - pip install --upgrade pip setuptools wheel + - pip install --only-binary=numpy,scipy numpy scipy script: - - python -m unittest discover --pattern=*_test.py + - python -m unittest discover tests notifications: email: on_success: never diff --git a/tests/example_test.py b/tests/example_test.py deleted file mode 100644 index e8372ba..0000000 --- a/tests/example_test.py +++ /dev/null @@ -1,10 +0,0 @@ -import unittest - - -class ExampleTest(unittest.TestCase): - def test(self): - self.assertTrue(True) - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/test_utils.py b/tests/test_utils.py new file mode 100644 index 0000000..c2bdea2 --- /dev/null +++ b/tests/test_utils.py @@ -0,0 +1,27 @@ +import unittest +import utils + +from tempfile import mkdtemp +from shutil import rmtree +from os import path + + +class TestUtils(unittest.TestCase): + def setUp(self): + self.test_dir = mkdtemp() + + def tearDown(self): + rmtree(self.test_dir) + + def test_read_text_file(self): + file_path = path.join(self.test_dir, 'tmp.txt') + content = 'test' + + with open(file_path, 'w') as f: + f.write(content) + + self.assertEqual(utils.read_text_file(file_path), content) + + +if __name__ == '__main__': + unittest.main()