File tree 3 files changed +8
-11
lines changed
3 files changed +8
-11
lines changed Original file line number Diff line number Diff line change
1
+ /.cache
1
2
/.tox
2
3
/venv
3
4
__pycache__ /
Original file line number Diff line number Diff line change 4
4
@pytest .fixture (autouse = True )
5
5
def etc (fs ):
6
6
"""Use pyfakefs in every test case"""
7
- fs .add_real_directory ('configs' , target_path = '/etc/ocf' )
7
+ fs .add_real_directory ('configs' , target_path = '/etc/ocf' , read_only = True )
Original file line number Diff line number Diff line change 2
2
import os
3
3
4
4
import jsonschema
5
- import pytest
6
5
import yaml
6
+ from pyfakefs .fake_filesystem_unittest import Pause
7
7
8
- # Disable pyfakefs
9
- @pytest .fixture
10
- def etc ():
11
- pass
12
8
13
-
14
- def test_validate ():
15
- configs = yaml .safe_load (open ('configs/validate.yaml' )).items ()
9
+ def test_validate (fs ):
10
+ configs = yaml .safe_load (open ('/etc/ocf/validate.yaml' )).items ()
16
11
17
12
for shortname , metadata in configs :
18
13
schema_filename = os .path .join ('schemas' , metadata ['schema' ])
19
- config_filename = os .path .join ('configs ' , shortname + '.yaml' )
14
+ config_filename = os .path .join ('/etc/ocf ' , shortname + '.yaml' )
20
15
21
16
# PyYAML reads YAML date objects as Python date objects, which confuses
22
17
# jsonschema. To get around this, we convert the object to and from
@@ -25,6 +20,7 @@ def test_validate():
25
20
json .dumps (yaml .safe_load (open (config_filename )), default = str ),
26
21
)
27
22
28
- schema = json .load (open (schema_filename ))
23
+ with Pause (fs ):
24
+ schema = json .load (open (schema_filename ))
29
25
30
26
jsonschema .validate (config , schema )
You can’t perform that action at this time.
0 commit comments