Completed
Pull Request — master (#22)
by Jerome
01:49
created

WindowsError   A

Complexity

Total Complexity 0

Size/Duplication

Total Lines 2
Duplicated Lines 0 %

Importance

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