1
|
|
|
# pylint: disable=missing-docstring,expression-not-assigned,unused-variable |
2
|
|
|
|
3
|
|
|
import os |
4
|
|
|
|
5
|
|
|
import pytest |
6
|
|
|
from expecter import expect |
|
|
|
|
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
|
|
|
|
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.
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.