File tree Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Original file line number Diff line number Diff line change 1
1
import json
2
- import os
3
2
import re
4
- import sys
3
+ from pathlib import Path
5
4
6
- FIXTURES_DIR = sys . path [ 0 ] + "/test/ fixtures"
5
+ FIXTURES_DIR = Path ( __file__ ). parent . parent / " fixtures"
7
6
8
7
# This regex is useful for finding individual underscore characters,
9
8
# which is necessary to allow us to use underscores in URL paths.
@@ -30,18 +29,18 @@ def _load_fixtures(self):
30
29
"""
31
30
self .fixtures = {}
32
31
33
- for json_file in os . listdir ( FIXTURES_DIR ):
34
- if not json_file .endswith ( ".json" ) :
32
+ for json_file in FIXTURES_DIR . iterdir ( ):
33
+ if json_file .suffix != ".json" :
35
34
continue
36
35
37
- with open (FIXTURES_DIR + "/" + json_file ) as f :
36
+ with open (json_file ) as f :
38
37
raw = f .read ()
39
38
40
39
data = json .loads (raw )
41
40
42
- fixture_url = PATH_REPLACEMENT_REGEX .sub ("/" , json_file ). replace (
43
- "__ " , "_"
44
- )[:- 5 ]
41
+ fixture_url = PATH_REPLACEMENT_REGEX .sub (
42
+ "/ " , json_file . name
43
+ ). replace ( "__" , "_" ) [:- 5 ]
45
44
46
45
self .fixtures [fixture_url ] = data
47
46
You can’t perform that action at this time.
0 commit comments