Completed
Push — develop ( ac1289...37ee14 )
by Jace
6s
created

yorm.test.describe_delete()   B

Complexity

Conditions 6

Size

Total Lines 27

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 6
dl 0
loc 27
rs 7.5384

5 Methods

Rating   Name   Duplication   Size   Complexity  
A yorm.test.it_ignores_missing_files() 0 2 1
A yorm.test.existing_path() 0 7 1
A yorm.test.it_deletes_directories() 0 3 1
A yorm.test.it_deletes_existing_files() 0 3 1
A yorm.test.existing_dirpath() 0 6 1
1
# pylint: disable=missing-docstring,expression-not-assigned,unused-variable
2
3
import os
4
5
import pytest
6
from expecter import expect
0 ignored issues
show
Configuration introduced by
The import expecter could not be resolved.

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
7
8
from yorm import diskutils
9
10
11
def describe_touch():
12
13
    @pytest.fixture
14
    def new_path(tmpdir):
15
        tmpdir.chdir()
16
        return os.path.join('.', 'file.ext')
17
18
    @pytest.fixture
19
    def new_path_in_directory():
20
        dirpath = os.path.join('path', 'to', 'directory')
21
        return os.path.join(dirpath, 'file.ext')
22
23
    def it_creates_files(new_path):
24
        diskutils.touch(new_path)
25
        expect(os.path.exists(new_path)).is_true()
26
27
    def it_can_be_called_twice(new_path):
28
        diskutils.touch(new_path)
29
        diskutils.touch(new_path)
30
        expect(os.path.exists(new_path)).is_true()
31
32
    def it_creates_missing_directories(new_path_in_directory):
33
        diskutils.touch(new_path_in_directory)
34
        expect(os.path.exists(new_path_in_directory)).is_true()
35
36
37
def describe_delete():
38
39
    @pytest.fixture
40
    def existing_path(tmpdir):
41
        tmpdir.chdir()
42
        path = "path/to/file.ext"
43
        os.makedirs(os.path.dirname(path))
44
        open(path, 'w').close()
45
        return path
46
47
    @pytest.fixture
48
    def existing_dirpath(tmpdir):
49
        tmpdir.chdir()
50
        dirpath = "path/to/directory"
51
        os.makedirs(dirpath)
52
        return dirpath
53
54
    def it_deletes_existing_files(existing_path):
55
        diskutils.delete(existing_path)
56
        expect(os.path.exists(existing_path)).is_false()
57
58
    def it_ignores_missing_files():
59
        diskutils.delete("path/to/non/file")
60
61
    def it_deletes_directories(existing_dirpath):
62
        diskutils.delete(existing_dirpath)
63
        expect(os.path.exists(existing_dirpath)).is_false()
64