Completed
Pull Request — master (#22)
by Jerome
44s
created

ProjectTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 14
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A test_integration() 0 9 3
A test_init() 0 3 1
1
from msquaredc.project import Project
2
import unittest,os
3
4
def test_cleanup(func):
5
    def call(*args,**kwargs):
6
        try:
7
            os.remove(func.__name__)
8
        except (PermissionError,FileNotFoundError):
9
            pass
10
        try:
11
            res = func(*args, file=func.__name__,**kwargs)
12
        finally:
13
            try:
14
                os.remove(func.__name__)
15
            except (PermissionError, FileNotFoundError):
16
                pass
17
        return res
18
    return call
19
20
21
class ProjectTest(unittest.TestCase):
22
    @test_cleanup
23
    def test_init(self,file):
24
        p = Project(data="data sample for jerome.txt", questions="config.yml", coder="MGM", file=file)
25
26
    @test_cleanup
27
    def test_integration(self,file):
28
        p = Project(data="data sample for jerome.txt", questions="config.yml", coder="MGM", file=file)
29
        value = 0
30
        for index,i in enumerate(p):
31
            for j in i.coding_questions:
32
                i[j] = value
33
                value += 1
34
        p.export()
35