import doctest
import sys
if hasattr(doctest, "testfile"):
    print("=== Test file: README ===")
    failure, tests = doctest.testfile('README', optionflags=doctest.ELLIPSIS)
    if failure:
        sys.exit(1)

    print("=== Test file: test.rst ===")
    failure, tests = doctest.testfile('test/test.rst', optionflags=doctest.ELLIPSIS)
    if failure:
        sys.exit(1)

    print("=== Test IPy module ===")
    import IPy
    failure, tests = doctest.testmod(IPy)
    if failure:
        sys.exit(1)
else:
    sys.stderr.write("WARNING: doctest has no function testfile (before Python 2.4), unable to check README\n")


import doctest
import sys
if hasattr(doctest, "testfile"):
    total_failures, total_tests = (0, 0)

    print("=== Test file: README ===")
    failure, tests = doctest.testfile('README', optionflags=doctest.ELLIPSIS)
    total_failures += failure
    total_tests += tests

    print("=== Test file: test.rst ===")
    failure, tests = doctest.testfile('test/test.rst', optionflags=doctest.ELLIPSIS)
    total_failures += failure
    total_tests += tests

    print("=== Test IPy module ===")
    import IPy
    failure, tests = doctest.testmod(IPy)
    total_failures += failure
    total_tests += tests

    print("=== Overall Results ===")
    print("total tests %d, failures %d" % (total_tests, total_failures))
    if total_failures:
        sys.exit(1)
else:
    sys.stderr.write("WARNING: doctest has no function testfile (before Python 2.4), unable to check README\n")


Allow doctest runner to keep going after failures
Allow doctest runner to keep going after failures

It will still return an error code, but there is little need to halt the
running of the three different doctest modules if an early one fails,
which may in fact mask the real reason for failure in an IPy internal
method.

Signed-off-by: Dan McGee <a6e5737275ff1276377ee261739f3ee963671241@gmail.com>

  import doctest
  import sys
  if hasattr(doctest, "testfile"):
+     total_failures, total_tests = (0, 0)
+ 
      print("=== Test file: README ===")
      failure, tests = doctest.testfile('README', optionflags=doctest.ELLIPSIS)
-     if failure:
-         sys.exit(1)
+     total_failures += failure
+     total_tests += tests
  
      print("=== Test file: test.rst ===")
      failure, tests = doctest.testfile('test/test.rst', optionflags=doctest.ELLIPSIS)
-     if failure:
-         sys.exit(1)
+     total_failures += failure
+     total_tests += tests
  
      print("=== Test IPy module ===")
      import IPy
      failure, tests = doctest.testmod(IPy)
+     total_failures += failure
+     total_tests += tests
+ 
+     print("=== Overall Results ===")
+     print("total tests %d, failures %d" % (total_tests, total_failures))
-     if failure:
+     if total_failures:
          sys.exit(1)
  else:
      sys.stderr.write("WARNING: doctest has no function testfile (before Python 2.4), unable to check README\n")
  
  
Allow doctest runner to keep going after failures
## Code Before:
import doctest
import sys
if hasattr(doctest, "testfile"):
    print("=== Test file: README ===")
    failure, tests = doctest.testfile('README', optionflags=doctest.ELLIPSIS)
    if failure:
        sys.exit(1)

    print("=== Test file: test.rst ===")
    failure, tests = doctest.testfile('test/test.rst', optionflags=doctest.ELLIPSIS)
    if failure:
        sys.exit(1)

    print("=== Test IPy module ===")
    import IPy
    failure, tests = doctest.testmod(IPy)
    if failure:
        sys.exit(1)
else:
    sys.stderr.write("WARNING: doctest has no function testfile (before Python 2.4), unable to check README\n")


## Instruction:
Allow doctest runner to keep going after failures
## Code After:
import doctest
import sys
if hasattr(doctest, "testfile"):
    total_failures, total_tests = (0, 0)

    print("=== Test file: README ===")
    failure, tests = doctest.testfile('README', optionflags=doctest.ELLIPSIS)
    total_failures += failure
    total_tests += tests

    print("=== Test file: test.rst ===")
    failure, tests = doctest.testfile('test/test.rst', optionflags=doctest.ELLIPSIS)
    total_failures += failure
    total_tests += tests

    print("=== Test IPy module ===")
    import IPy
    failure, tests = doctest.testmod(IPy)
    total_failures += failure
    total_tests += tests

    print("=== Overall Results ===")
    print("total tests %d, failures %d" % (total_tests, total_failures))
    if total_failures:
        sys.exit(1)
else:
    sys.stderr.write("WARNING: doctest has no function testfile (before Python 2.4), unable to check README\n")

