Completed
Push — master ( db34c1...589162 )
by Jerome
12s
created

WindowsError   A

Complexity

Total Complexity 0

Size/Duplication

Total Lines 2
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 2
rs 10
wmc 0
1
import os
2
import unittest
3
4
from msquaredc.project import Project
5
6
7
class PermissionError(IOError):
8
    pass
9
10
class FileNotFoundError(IOError):
11
    pass
12
13
class WindowsError(IOError):
14
    pass
15
16
def cleanup(func):
17
    def call(*args,**kwargs):
18
        try:
19
            if os.path.isfile(func.__name__):
20
                os.remove(func.__name__)
21
        except (PermissionError,FileNotFoundError,WindowsError) as e:
22
            pass
23
        try:
24
            res = func(*args, file=func.__name__,**kwargs)
25
        finally:
26
            try:
27
                if os.path.isfile(func.__name__):
28
                    os.remove(func.__name__)
29
            except (PermissionError, FileNotFoundError,WindowsError) as e:
30
                pass
31
        return res
32
    return call
33
34
35
class ProjectTest(unittest.TestCase):
36
    pass
37
"""    
38
    @cleanup
39
    def test_init(self,file):
40
        p = Project(data="data.txt", questions="config.yml", coder="MGM", file=file)
41
42
    @cleanup
43
    def test_integration(self,file):
44
        p = Project(data="data.txt", questions="config.yml", coder="MGM", file=file)
45
        value = 0
46
        for index,i in enumerate(p):
47
            for j in i.coding_questions:
48
                i[j] = value
49
                value += 1
50
        p.export()
51
"""
52