Completed
Push — develop ( 4ae7a2...f1348d )
by Jace
02:26
created

yorm.test.it_creates_missing_directories()   A

Complexity

Conditions 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 1
dl 0
loc 3
rs 10
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 common
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
        common.touch(new_path)
25
        expect(os.path.exists(new_path)).is_true()
26
27
    def it_can_be_called_twice(new_path):
28
        common.touch(new_path)
29
        common.touch(new_path)
30
        expect(os.path.exists(new_path)).is_true()
31
32
    def it_creates_missing_directories(new_path_in_directory):
33
        common.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.system("touch {}".format(path))
44
        return path
45
46
    @pytest.fixture
47
    def existing_dirpath(tmpdir):
48
        tmpdir.chdir()
49
        dirpath = "path/to/directory"
50
        os.system("mkdir -p {}".format(dirpath))
51
        return dirpath
52
53
    def it_deletes_existing_files(existing_path):
54
        common.delete(existing_path)
55
        expect(os.path.exists(existing_path)).is_false()
56
57
    def it_ignores_missing_files():
58
        common.delete("path/to/non/file")
59
60
    def it_deletes_directories(existing_dirpath):
61
        common.delete(existing_dirpath)
62
        expect(os.path.exists(existing_dirpath)).is_false()
63