Skip to content

Commit

Permalink
* set zip_safe=True
Browse files Browse the repository at this point in the history
* update setup.py and restructure \"run unittests\" stuff
  • Loading branch information
jedie committed Oct 17, 2011
1 parent 2397d24 commit d33406a
Show file tree
Hide file tree
Showing 4 changed files with 154 additions and 117 deletions.
122 changes: 120 additions & 2 deletions creole/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,129 @@
#!/usr/bin/env python
# coding: utf-8

"""
run all unittests
~~~~~~~~~~~~~~~~~
:copyleft: 2008-2011 by python-creole team, see AUTHORS for more details.
:license: GNU GPL v3 or above, see LICENSE for more details.
"""

from __future__ import division, absolute_import, print_function, unicode_literals

from doctest import testmod
import os
import sys
import time
import unittest

from . import run_all_tests as all_tests
import creole
from creole.tests import all_tests


SKIP_DIRS = (".settings", ".git", "dist", "python_creole.egg-info")
SKIP_FILES = ("setup.py", "test.py")


if "-v" in sys.argv or "--verbosity" in sys.argv:
VERBOSE = 2
elif "-q" in sys.argv or "--quite" in sys.argv:
VERBOSE = 0
else:
VERBOSE = 1


def run_all_doctests(verbosity=None):
"""
run all python-creole DocTests
"""
start_time = time.time()
if verbosity is None:
verbosity = VERBOSE

path = os.path.abspath(os.path.dirname(creole.__file__))
if verbosity >= 2:
print("")
print("_" * 79)
print("Running %r DocTests:\n" % path)

total_files = 0
total_doctests = 0
total_attempted = 0
total_failed = 0
for root, dirs, filelist in os.walk(path, followlinks=True):
for skip_dir in SKIP_DIRS:
if skip_dir in dirs:
dirs.remove(skip_dir) # don't visit this directories

for filename in filelist:
if not filename.endswith(".py"):
continue
if filename in SKIP_FILES:
continue

total_files += 1

def run_all_tests():
sys.path.insert(0, root)
try:
m = __import__(filename[:-3])
except ImportError as err:
if verbosity >= 2:
print("***DocTest import %s error*** %s" % (filename, err))
except Exception as err:
if verbosity >= 2:
print("***DocTest %s error*** %s" % (filename, err))
else:
failed, attempted = testmod(m)
total_attempted += attempted
total_failed += failed
if attempted or failed:
total_doctests += 1

if attempted and not failed:
filepath = os.path.join(root, filename)
if verbosity <= 1:
sys.stdout.write(".")
elif verbosity >= 2:
print("DocTest in %s OK (failed=%i, attempted=%i)" % (
filepath, failed, attempted
))
finally:
del sys.path[0]

duration = time.time() - start_time
print("")
print("-"*70)
print("Ran %i DocTests from %i files in %.3fs: failed=%i, attempted=%i\n\n" % (
total_doctests, total_files, duration, total_failed, total_attempted
))



def get_test_suite():
"""
return the unittest.TestSuite for setup.py
"""
suite = unittest.findTestCases(all_tests)
return suite


def run_unittests(verbosity=None):
"""
run all python-creole unittests
"""
if verbosity is None:
verbosity = VERBOSE

if verbosity >= 2:
print("")
print("_" * 79)
print("Running Unittests:\n")

unittest.main(verbosity=verbosity)


if __name__ == '__main__':
run_all_doctests()
run_unittests()

23 changes: 23 additions & 0 deletions creole/tests/all_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env python
# coding: utf-8

"""
run all unittests
~~~~~~~~~~~~~~~~~
:copyleft: 2008-2011 by python-creole team, see AUTHORS for more details.
:license: GNU GPL v3 or above, see LICENSE for more details.
"""

from __future__ import division, absolute_import, print_function, unicode_literals

from creole.tests.test_creole2html import TestCreole2html, TestCreole2htmlMarkup, TestStr2Dict, TestDict2String
from creole.tests.test_cross_compare_all import CrossCompareTests
from creole.tests.test_cross_compare_creole import CrossCompareCreoleTests
from creole.tests.test_cross_compare_rest import CrossCompareReStTests
from creole.tests.test_cross_compare_textile import CrossCompareTextileTests
from creole.tests.test_html2creole import TestHtml2Creole, TestHtml2CreoleMarkup
from creole.tests.test_rest2html import ReSt2HtmlTests
from creole.tests.test_setup_utils import SetupUtilsTests
from creole.tests.test_utils import UtilsTests
from creole.tests.utils.utils import MarkupTest
110 changes: 0 additions & 110 deletions creole/tests/run_all_tests.py

This file was deleted.

16 changes: 11 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import os
import sys

from setuptools import setup, find_packages
from setuptools import setup, find_packages, Command

from creole import VERSION_STRING
from creole.setup_utils import get_long_description
Expand Down Expand Up @@ -44,19 +44,25 @@ def get_authors():
packages=find_packages(),
include_package_data=True, # include package data under svn source control
data_files=[("", ["README.creole"])], # README used in unittest test_setup_utils.py
zip_safe=False,
zip_safe=True, # http://packages.python.org/distribute/setuptools.html#setting-the-zip-safe-flag
keywords="creole markup creole2html html2creole rest2html html2rest html2textile",
classifiers=[
# http://pypi.python.org/pypi?%3Aaction=list_classifiers
# "Development Status :: 4 - Beta",
"Development Status :: 5 - Production/Stable",
"Environment :: Web Environment",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU General Public License (GPL)",
"Topic :: Documentation",
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
"Topic :: Documentation",
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Text Processing :: Markup",
"Topic :: Text Processing :: Markup :: HTML"
"Topic :: Utilities",
],
test_suite="creole.tests.run_all_tests",
test_suite="creole.tests.get_test_suite",
)

0 comments on commit d33406a

Please sign in to comment.