Skip to content

Commit

Permalink
Remove Python 2 code
Browse files Browse the repository at this point in the history
  • Loading branch information
vstinner committed Apr 13, 2023
1 parent f010fcb commit b1af07d
Showing 1 changed file with 8 additions and 19 deletions.
27 changes: 8 additions & 19 deletions runtests.py
Expand Up @@ -21,25 +21,22 @@
# Originally written by Beech Horn (for NDB).

from __future__ import print_function
import optparse
import gc
import importlib.machinery
import logging
import optparse
import os
import re
import sys
import textwrap
import unittest.signals

from hachoir.test import setup_tests
try:
import coverage
except ImportError:
coverage = None

try:
import unittest
from unittest.signals import installHandler
except ImportError:
import unittest2 as unittest
from unittest2.signals import installHandler

ARGS = optparse.OptionParser(description="Run all unittests.", usage="%prog")
ARGS.add_option(
Expand Down Expand Up @@ -72,17 +69,9 @@
help='optional regex patterns to match test ids (default all tests)')


if sys.version_info >= (3, 3):
import importlib.machinery

def load_module(modname, sourcefile):
loader = importlib.machinery.SourceFileLoader(modname, sourcefile)
return loader.load_module()
else:
import imp

def load_module(modname, sourcefile):
return imp.load_source(modname, sourcefile)
def load_module(modname, sourcefile):
loader = importlib.machinery.SourceFileLoader(modname, sourcefile)
return loader.load_module()


def load_modules(basedir, suffix='.py'):
Expand Down Expand Up @@ -262,7 +251,7 @@ def runtests():
elif v >= 4:
logger.setLevel(logging.DEBUG)
if catchbreak:
installHandler()
unittest.signals.installHandler()
try:
if args.forever:
while True:
Expand Down

0 comments on commit b1af07d

Please sign in to comment.