mirror of
https://github.com/wassname/catalyst.git
synced 2026-06-27 19:30:28 +08:00
MAINT: Make walk usage in example tests compatible with Python 3
The rename of walk is not provided by six, so check the import error via an exception. Also, callback behavior slightly changes between the two versions, so instead iterate over the walked files and call what was formerly a callback, directly as a function.
This commit is contained in:
+11
-3
@@ -21,15 +21,22 @@
|
||||
import matplotlib
|
||||
matplotlib.use('Agg')
|
||||
|
||||
from os import path
|
||||
import os
|
||||
from os import path
|
||||
|
||||
try:
|
||||
from path import walk
|
||||
except ImportError:
|
||||
# Assume Python 3
|
||||
from os import walk
|
||||
|
||||
import fnmatch
|
||||
import imp
|
||||
|
||||
|
||||
def test_examples():
|
||||
os.chdir(example_dir())
|
||||
for fname in all_matching_files('.', '*.py'):
|
||||
for fname in all_matching_files(example_dir(), '*.py'):
|
||||
yield check_example, fname
|
||||
|
||||
|
||||
@@ -40,7 +47,8 @@ def all_matching_files(d, pattern):
|
||||
fls.extend(nfiles)
|
||||
|
||||
files = []
|
||||
path.walk(d, addfiles, files)
|
||||
for dirpath, dirnames, filenames in walk(d):
|
||||
addfiles(files, dirpath, filenames)
|
||||
return files
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user