-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pushing latest fixes and features to dev (#46)
* Adding 2017 to LICENSE * Adding inital test suite * Fix incorrect header argument * Adding game metadata support (MMR, etc)
- Loading branch information
Showing
7 changed files
with
109 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
|
||
*.swp | ||
*.swo | ||
*~ | ||
|
||
*.SC2Replay | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
__author__ = 'Blizzard Entertainment' | ||
__version__ = (1, 0, 1, 'dev') | ||
__all__ = [ 'versions', 'diff', 's2_cli' ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/usr/bin/python | ||
|
||
import sys | ||
import unittest | ||
import os | ||
import inspect | ||
import re | ||
|
||
from optparse import OptionParser | ||
|
||
# | ||
# Fix up import path if running directly | ||
# | ||
if __name__ == '__main__': | ||
filename = os.path.abspath(inspect.getfile(inspect.currentframe())) | ||
thispath = os.path.dirname(filename) | ||
normpath = os.path.normpath(os.path.join(thispath, os.pardir)) | ||
sys.path.insert(0, normpath) | ||
|
||
import s2protocol | ||
import test_versions | ||
|
||
|
||
def run(): | ||
parser = OptionParser() | ||
parser.add_option('-l', '--list', dest='list', action='store_true', | ||
help='List all test cases') | ||
parser.add_option('-r', '--requests', dest='requests', action='store_true', | ||
help='Enable logging of requests') | ||
parser.add_option('-v', '--verbose', dest='verbose', action='store_true', | ||
help='Enable verbose logging') | ||
parser.add_option('-f', '--filter', dest='filter', type='string', action='store', | ||
help='Filter test cases with a regular expression') | ||
options, args = parser.parse_args() | ||
|
||
all_tests = [ | ||
test_versions.suite(), | ||
] | ||
|
||
if options.list: | ||
for suite in all_tests: | ||
for t in suite: | ||
print t.id() | ||
return | ||
|
||
if options.filter: | ||
pattern = re.compile(options.filter) | ||
def expand_tests(): | ||
for suite in all_tests: | ||
for t in suite: | ||
yield t | ||
|
||
def pattern_match(test): | ||
name = test.id() | ||
return pattern.match(name) is not None | ||
all_tests = unittest.TestSuite(filter(pattern_match, expand_tests())) | ||
else: | ||
all_tests = unittest.TestSuite(all_tests) | ||
|
||
test_verbosity = 1 | ||
if options.verbose: | ||
test_verbosity = 3 | ||
|
||
unittest.TextTestRunner(verbosity=test_verbosity, failfast=True).run(all_tests) | ||
|
||
if __name__ == '__main__': | ||
run() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import unittest | ||
from s2protocol import versions as _versions | ||
|
||
class VersionsTestCase(unittest.TestCase): | ||
def test_latest(self): | ||
p = _versions.latest() | ||
self.assertIsNotNone(p) | ||
|
||
def test_specific(self): | ||
p = _versions.build(49716) | ||
self.assertIsNotNone(p) | ||
|
||
def test_missing(self): | ||
self.assertRaises(ImportError, lambda: _versions.build(42)) | ||
|
||
|
||
def suite(): | ||
return unittest.TestLoader().loadTestsFromTestCase(VersionsTestCase) |