From c6609fd4dacf7347125fdf3d4cf4ac1afeef7d4d Mon Sep 17 00:00:00 2001 From: Vincent Jacques Date: Sun, 16 Sep 2012 20:39:00 +0200 Subject: [PATCH] Fixes for issue #86 --- .gitignore | 2 -- github/tests/AllTests.py | 58 +++++++++++++++++++++++++++++++++++++++ github/tests/Framework.py | 9 ++---- github/tests/__init__.py | 19 +++++++++++++ github/tests/__main__.py | 15 ++++++++++ publish.sh | 2 +- run_tests.sh | 16 ----------- setup.py | 17 ++++++------ 8 files changed, 104 insertions(+), 34 deletions(-) create mode 100644 github/tests/AllTests.py create mode 100644 github/tests/__init__.py create mode 100644 github/tests/__main__.py delete mode 100755 run_tests.sh diff --git a/.gitignore b/.gitignore index 3af5a479..4b032645 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,4 @@ *.pyc GithubCredentials.py -.coverage /dist /MANIFEST -/test/htmlcov/ diff --git a/github/tests/AllTests.py b/github/tests/AllTests.py new file mode 100644 index 00000000..71453e57 --- /dev/null +++ b/github/tests/AllTests.py @@ -0,0 +1,58 @@ +# Copyright 2012 Vincent Jacques +# vincent@vincent-jacques.net + +# This file is part of PyGithub. http://vincent-jacques.net/PyGithub + +# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + +# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see . + +from AuthenticatedUser import * +from Authentication import * +from Authorization import * +from Branch import * +from Commit import * +from CommitComment import * +from CommitStatus import * +from ContentFile import * +from Download import * +from Event import * +from Gist import * +from GistComment import * +from GitBlob import * +from GitCommit import * +from Github import * +from GitRef import * +from GitTag import * +from GitTree import * +from Hook import * +from Issue import * +from IssueComment import * +from IssueEvent import * +from Label import * +from Milestone import * +from NamedUser import * +from Markdown import * +from Organization import * +from PullRequest import * +from PullRequestComment import * +from PullRequestFile import * +from RateLimiting import * +from Repository import * +from RepositoryKey import * +from Tag import * +from Team import * +from UserKey import * + +from PaginatedList import * +from Exceptions import * +from Enterprise import * + +from Issue33 import * +from Issue50 import * +from Issue54 import * +from Issue80 import * diff --git a/github/tests/Framework.py b/github/tests/Framework.py index 597c64e1..cf1dc896 100644 --- a/github/tests/Framework.py +++ b/github/tests/Framework.py @@ -16,9 +16,7 @@ import sys import unittest import httplib import traceback -import itertools -sys.path = [ os.path.join( os.path.dirname( __file__ ), ".." ) ] + sys.path import github class FakeHttpResponse: @@ -175,8 +173,5 @@ class TestCase( BasicTestCase ): BasicTestCase.setUp( self ) self.g = github.Github( self.login, self.password ) -def main(): - if "--record" in sys.argv: - BasicTestCase.recordMode = True - - unittest.main( argv = [ arg for arg in sys.argv if arg != "--record" ] ) +def activateRecordMode(): + BasicTestCase.recordMode = True diff --git a/github/tests/__init__.py b/github/tests/__init__.py new file mode 100644 index 00000000..7e573b50 --- /dev/null +++ b/github/tests/__init__.py @@ -0,0 +1,19 @@ +# Copyright 2012 Vincent Jacques +# vincent@vincent-jacques.net + +# This file is part of PyGithub. http://vincent-jacques.net/PyGithub + +# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + +# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see . + +import unittest + +import AllTests + +def run(): + unittest.main( module = AllTests, argv = [ "Dummy Script Name" ] ) diff --git a/github/tests/__main__.py b/github/tests/__main__.py new file mode 100644 index 00000000..494c50c1 --- /dev/null +++ b/github/tests/__main__.py @@ -0,0 +1,15 @@ +import sys +import unittest + +import Framework +import AllTests + +def main( argv ): + if "--record" in argv: + Framework.activateRecordMode() + argv = [ arg for arg in argv if arg != "--record" ] + + unittest.main( module = AllTests, argv = argv ) + +if __name__ == "__main__": + main( sys.argv ) diff --git a/publish.sh b/publish.sh index e48b99c1..8bb6f9da 100755 --- a/publish.sh +++ b/publish.sh @@ -1,6 +1,6 @@ #!/bin/sh -./run_tests.sh +python setup.py test previousVersion=$( grep 'version =' setup.py | sed 's/.*version = \"\(.*\)\".*/\1/' ) echo "Next version number? (previous: '$previousVersion')" diff --git a/run_tests.sh b/run_tests.sh deleted file mode 100755 index 38ad3b7e..00000000 --- a/run_tests.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - -rm -f $(find . -name "*.pyc") - -cd test - -coverage erase -coverage run --branch IntegrationTest.py - -echo "==============================" -echo "|| Coverage (shall be 100%) ||" -echo "==============================" - -coverage report -m --include=../github/* - -coverage html --include=../github/* diff --git a/setup.py b/setup.py index 52f1c295..69baf89c 100755 --- a/setup.py +++ b/setup.py @@ -16,18 +16,18 @@ from distutils.core import setup, Command import textwrap -class TestCommand( Command ): +class test( Command ): user_options = [] - def initialize_options(self): + def initialize_options( self ): pass - def finalize_options(self): + def finalize_options( self ): pass - def run(self): - import sys, subprocess - raise SystemExit( subprocess.call( [ sys.executable, "test/IntegrationTest.py" ] ) ) + def run( self ): + import github.tests + github.tests.run() setup( name = "PyGithub", @@ -66,9 +66,10 @@ setup( See http://vincent-jacques.net/PyGithub""" ), packages = [ "github", + "github.tests", ], package_data = { - "github": [ "ReadMe.md", "COPYING*", "doc/*.md" ] + "github": [ "ReadMe.md", "COPYING*", "doc/*.md", "tests/ReplayData/*.txt" ] }, classifiers = [ "Development Status :: 5 - Production/Stable", @@ -79,5 +80,5 @@ setup( "Programming Language :: Python", "Topic :: Software Development", ], - cmdclass = { "test": TestCommand }, + cmdclass = { "test": test }, )