File: test_task_misc.py

package info (click to toggle)
python-ruffus 2.8.4-8
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 16,492 kB
  • sloc: python: 17,613; makefile: 213; sh: 18
file content (63 lines) | stat: -rwxr-xr-x 1,697 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python
from __future__ import print_function
import unittest
from ruffus import task
from ruffus import ruffus_exceptions

"""
    test_task_misc.py
"""

import os
import sys

# add grandparent to search path for testing
grandparent_dir = os.path.abspath(
    os.path.join(os.path.dirname(__file__), "..", ".."))
sys.path.insert(0, grandparent_dir)

# module name = script name without extension
module_name = os.path.splitext(os.path.basename(__file__))[0]


# funky code to import by file name
parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))


class Test_needs_update_check_directory_missing(unittest.TestCase):

    def setUp(self):
        """
        Create temp directory and temp file
        """
        import tempfile

        # test_file =tempfile.NamedTemporaryFile(delete=False)
        # self.tempfile = test_file.name
        # test_file.close()
        fh, self.tempfile = tempfile.mkstemp(suffix='.dot')
        os.fdopen(fh, "w").close()
        self.directory = tempfile.mkdtemp(prefix='testing_tmp')

    def tearDown(self):
        """
        delete files
        """
        os.unlink(self.tempfile)
        os.removedirs(self.directory)

    def test_up_to_date(self):
        #
        #   lists of files
        #

        self.assertTrue(
            not task.needs_update_check_directory_missing([self.directory])[0])
        self.assertTrue(task.needs_update_check_directory_missing(
            ["missing directory"])[0])
        self.assertRaises(ruffus_exceptions.error_not_a_directory,
                          task.needs_update_check_directory_missing, [self.tempfile])


if __name__ == '__main__':
    unittest.main()