Skip to content

Commit

Permalink
merge cjw296/handle_broken_modules
Browse files Browse the repository at this point in the history
  • Loading branch information
cjw296 committed Jul 14, 2014
2 parents e1775bd + b98b169 commit 94303b4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 32 deletions.
23 changes: 0 additions & 23 deletions src/manuel/__init__.py
@@ -1,6 +1,4 @@
import imp
import re
import sys

# constants for use with "timing" decorator
EARLY = 'early'
Expand All @@ -15,27 +13,6 @@ def decorate(func):
return decorate


def normalize_module_path(module_path):
if module_path.endswith('.pyc'):
module_path = module_path[:-1]
return module_path


def absolute_import(name):
fp, filename, (suffix, mode, type) = imp.find_module(name)
fp.close()
module_path = normalize_module_path(filename)

# don't create a new module object if there's already one that we can reuse
for module in list(sys.modules.values()):
if module is None or not hasattr(module, '__file__'):
continue
if module_path == normalize_module_path(module.__file__):
return module

return imp.load_module(name, *imp.find_module(name))


def newlineify(s):
if s == '' or s[-1] != '\n':
s += '\n'
Expand Down
5 changes: 3 additions & 2 deletions src/manuel/doctest.py
@@ -1,9 +1,10 @@
from __future__ import absolute_import

import doctest
import six
import manuel
import os.path

doctest = manuel.absolute_import('doctest')

DocTestRunner = doctest.DocTestRunner
DebugRunner = doctest.DebugRunner

Expand Down
6 changes: 3 additions & 3 deletions src/manuel/testing.py
@@ -1,13 +1,13 @@
from . import doctest
from __future__ import absolute_import

import doctest as real_doctest
import inspect
import itertools
import manuel
import os.path
import sys
import unittest

real_doctest = manuel.absolute_import('doctest')

__all__ = ['TestSuite']

class TestCaseMarker(object):
Expand Down
7 changes: 3 additions & 4 deletions src/manuel/tests.py
@@ -1,4 +1,6 @@
from . import doctest
from __future__ import absolute_import

import doctest
import manuel
import manuel.capture
import manuel.codeblock
Expand All @@ -11,8 +13,6 @@
import unittest
import zope.testing.renormalizing

doctest = manuel.absolute_import('doctest')

here = os.path.dirname(os.path.abspath(__file__))

checker = zope.testing.renormalizing.RENormalizing([
Expand Down Expand Up @@ -52,7 +52,6 @@ def turtle_on_the_bottom_test():
"""


def test_suite():
tests = ['index.txt', 'table-example.txt', 'README.txt', 'bugs.txt',
'capture.txt']
Expand Down

0 comments on commit 94303b4

Please sign in to comment.