Last active
February 3, 2018 07:39
-
-
Save Xilesun/fa3136ca1b7acb95eec5a55208c4bce0 to your computer and use it in GitHub Desktop.
python代码段
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
# Import all files in modules dynamically | |
for module in os.listdir(os.path.dirname(__file__)): | |
if module == '__init__.py' or module[-3:] != '.py': | |
continue | |
__import__(module[:-3], locals(), globals()) | |
del module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Store testCase() in all files into modules array | |
modules = [] | |
for loader, name, is_pkg in pkgutil.walk_packages(testCase.__path__): | |
modules.append(loader.find_module(name).load_module(name)) | |
# Run every testCase(): | |
for module in modules: | |
module.testCase(self.key) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Take a screenshot of the results | |
# Get current file name | |
base = os.path.basename(__file__) | |
basename = os.path.splitext(base)[0] | |
path = os.path.join(group, basename) | |
if not os.path.isdir(path): | |
os.mkdir(path) | |
# Get timestamp | |
timestr = time.strftime("%Y%m%d%H%M%S") | |
filename = '%s.png' % timestr | |
pic = os.path.join(path, filename) | |
driver.save_screenshot(pic) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment