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 11import json
2- import os
32import re
4- import sys
3+ from pathlib import Path
54
6- FIXTURES_DIR = sys . path [ 0 ] + "/test/ fixtures"
5+ FIXTURES_DIR = Path ( __file__ ). parent . parent / " fixtures"
76
87# This regex is useful for finding individual underscore characters,
98# which is necessary to allow us to use underscores in URL paths.
@@ -30,18 +29,18 @@ def _load_fixtures(self):
3029 """
3130 self .fixtures = {}
3231
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 not json_file .suffix == ".json" :
3534 continue
3635
37- with open (FIXTURES_DIR + "/" + json_file ) as f :
36+ with open (FIXTURES_DIR / json_file ) as f :
3837 raw = f .read ()
3938
4039 data = json .loads (raw )
4140
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 ]
4544
4645 self .fixtures [fixture_url ] = data
4746
You can’t perform that action at this time.
0 commit comments