Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
package_control_channel
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Gaurav Kukreja
package_control_channel
Commits
71f32a7f
Commit
71f32a7f
authored
Dec 14, 2014
by
FichteFoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pretty-indent the tests
parent
f864654d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
31 deletions
+36
-31
test.py
tests/test.py
+36
-31
No files found.
tests/test.py
View file @
71f32a7f
...
@@ -27,7 +27,6 @@ if sys.version_info >= (3,):
...
@@ -27,7 +27,6 @@ if sys.version_info >= (3,):
generator_method_type
=
'method'
generator_method_type
=
'method'
str_cls
=
str
str_cls
=
str
else
:
else
:
from
.
import
unittest_compat
from
urlparse
import
urljoin
from
urlparse
import
urljoin
from
urllib2
import
HTTPError
,
urlopen
from
urllib2
import
HTTPError
,
urlopen
generator_method_type
=
'instancemethod'
generator_method_type
=
'instancemethod'
...
@@ -36,7 +35,8 @@ else:
...
@@ -36,7 +35,8 @@ else:
if
hasattr
(
sys
,
'argv'
):
if
hasattr
(
sys
,
'argv'
):
arglist
=
[
'--test-repositories'
]
arglist
=
[
'--test-repositories'
]
# Exctract used arguments form the commandline an strip them for unittest.main
# Exctract used arguments form the commandline an strip them for
# unittest.main
userargs
=
[
arg
for
arg
in
sys
.
argv
if
arg
in
arglist
]
userargs
=
[
arg
for
arg
in
sys
.
argv
if
arg
in
arglist
]
for
arg
in
userargs
:
for
arg
in
userargs
:
if
arg
in
sys
.
argv
:
if
arg
in
sys
.
argv
:
...
@@ -175,7 +175,8 @@ class TestContainer(object):
...
@@ -175,7 +175,8 @@ class TestContainer(object):
self
.
assertIn
(
'schema_version'
,
data
)
self
.
assertIn
(
'schema_version'
,
data
)
self
.
assertEqual
(
data
[
'schema_version'
],
'3.0.0'
)
self
.
assertEqual
(
data
[
'schema_version'
],
'3.0.0'
)
listkeys
=
[
k
for
k
in
(
'packages'
,
'dependencies'
,
'includes'
)
if
k
in
data
]
listkeys
=
[
k
for
k
in
(
'packages'
,
'dependencies'
,
'includes'
)
if
k
in
data
]
self
.
assertGreater
(
len
(
listkeys
),
0
)
self
.
assertGreater
(
len
(
listkeys
),
0
)
for
k
in
listkeys
:
for
k
in
listkeys
:
self
.
assertIsInstance
(
data
[
k
],
list
)
self
.
assertIsInstance
(
data
[
k
],
list
)
...
@@ -265,16 +266,16 @@ class TestContainer(object):
...
@@ -265,16 +266,16 @@ class TestContainer(object):
elif
k
==
'load_order'
:
elif
k
==
'load_order'
:
self
.
assertRegex
(
v
,
'^
\
d
\
d$'
,
'"load_order" must be a two '
self
.
assertRegex
(
v
,
'^
\
d
\
d$'
,
'"load_order" must be a two '
'digit string'
)
'digit string'
)
def
_test_release
(
self
,
package_name
,
data
,
main_repo
=
True
):
def
_test_release
(
self
,
package_name
,
data
,
main_repo
=
True
):
# Fail early
# Fail early
if
main_repo
:
if
main_repo
:
self
.
assert
Equal
(
True
,
(
'tags'
in
data
or
'branch'
in
data
),
self
.
assert
True
(
(
'tags'
in
data
or
'branch'
in
data
),
'A release must have a "tags" key or "branch" key '
'A release must have a "tags" key or "branch" key '
'if it is in the main repository. For custom '
'if it is in the main repository. For custom '
'releases, a custom repository.json file must be '
'releases, a custom repository.json file must be '
'hosted elsewhere.'
)
'hosted elsewhere.'
)
for
req
in
(
'url'
,
'version'
,
'date'
):
for
req
in
(
'url'
,
'version'
,
'date'
):
self
.
assertNotIn
(
req
,
data
,
self
.
assertNotIn
(
req
,
data
,
'The version, date and url keys should not be '
'The version, date and url keys should not be '
...
@@ -282,11 +283,10 @@ class TestContainer(object):
...
@@ -282,11 +283,10 @@ class TestContainer(object):
'request would be necessary for every release'
)
'request would be necessary for every release'
)
elif
'tags'
not
in
data
and
'branch'
not
in
data
:
elif
'tags'
not
in
data
and
'branch'
not
in
data
:
for
req
in
(
'url'
,
'version'
,
'date'
):
self
.
assertTrue
(
all
(
k
in
data
for
k
in
(
'url'
,
'version'
,
'date'
)),
self
.
assertIn
(
req
,
data
,
'A release must provide "url", "version" and '
'A release must provide "url", "version" and '
'"date" keys if it does not specify "tags" or'
'"date" keys if it does not specify "tags" or'
'"branch"'
)
'"branch"'
)
else
:
else
:
for
req
in
(
'url'
,
'version'
,
'date'
):
for
req
in
(
'url'
,
'version'
,
'date'
):
...
@@ -299,7 +299,7 @@ class TestContainer(object):
...
@@ -299,7 +299,7 @@ class TestContainer(object):
for
k
,
v
in
data
.
items
():
for
k
,
v
in
data
.
items
():
self
.
assertIn
(
k
,
(
'base'
,
'tags'
,
'branch'
,
'sublime_text'
,
self
.
assertIn
(
k
,
(
'base'
,
'tags'
,
'branch'
,
'sublime_text'
,
'platforms'
,
'version'
,
'date'
,
'url'
))
'platforms'
,
'version'
,
'date'
,
'url'
))
if
k
==
'date'
:
if
k
==
'date'
:
self
.
assertRegex
(
v
,
r"^\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d$"
)
self
.
assertRegex
(
v
,
r"^\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d$"
)
...
@@ -335,22 +335,25 @@ class TestContainer(object):
...
@@ -335,22 +335,25 @@ class TestContainer(object):
def
_test_dependency_release
(
self
,
package_name
,
data
,
main_repo
=
True
):
def
_test_dependency_release
(
self
,
package_name
,
data
,
main_repo
=
True
):
if
main_repo
:
if
main_repo
:
self
.
assertEqual
(
True
,
(
'tags'
in
data
or
'branch'
in
data
or
(
self
.
assertTrue
((
'tags'
in
data
'sha256'
in
data
and
'version'
in
data
and
'url'
in
data
and
or
'branch'
in
data
data
[
'url'
][
0
:
7
]
==
'http://'
)),
or
(
'sha256'
in
data
and
'version'
in
data
'A release must have a "tags" key or "branch" key '
and
'url'
in
data
'if it is in the main repository. For custom '
and
data
[
'url'
][
0
:
7
]
==
'http://'
)),
'releases, a custom repository.json file must be '
'A release must have a "tags" key or "branch" key '
'hosted elsewhere. The only exception to this rule '
'if it is in the main repository. For custom '
'is for packages that can not be served over HTTPS '
'releases, a custom repository.json file must be '
'since they help bootstrap proper secure HTTP '
'hosted elsewhere. The only exception to this rule '
'support for Sublime Text.'
)
'is for packages that can not be served over HTTPS '
'since they help bootstrap proper secure HTTP '
'support for Sublime Text.'
)
if
'sha256'
not
in
data
:
if
'sha256'
not
in
data
:
for
req
in
(
'url'
,
'version'
):
for
req
in
(
'url'
,
'version'
):
self
.
assertNotIn
(
req
,
data
,
self
.
assertNotIn
(
req
,
data
,
'The version and url keys should not be '
'The version and url keys should not be '
'used in the main repository since a pull '
'used in the main repository since a pull '
'request would be necessary for every release'
)
'request would be necessary for every '
'release.'
)
elif
'tags'
not
in
data
and
'branch'
not
in
data
:
elif
'tags'
not
in
data
and
'branch'
not
in
data
:
for
req
in
(
'url'
,
'version'
):
for
req
in
(
'url'
,
'version'
):
...
@@ -369,7 +372,7 @@ class TestContainer(object):
...
@@ -369,7 +372,7 @@ class TestContainer(object):
for
k
,
v
in
data
.
items
():
for
k
,
v
in
data
.
items
():
self
.
assertIn
(
k
,
(
'base'
,
'tags'
,
'branch'
,
'sublime_text'
,
self
.
assertIn
(
k
,
(
'base'
,
'tags'
,
'branch'
,
'sublime_text'
,
'platforms'
,
'version'
,
'url'
,
'sha256'
))
'platforms'
,
'version'
,
'url'
,
'sha256'
))
if
k
==
'url'
and
'sha256'
not
in
data
:
if
k
==
'url'
and
'sha256'
not
in
data
:
self
.
assertRegex
(
v
,
r'^https://'
)
self
.
assertRegex
(
v
,
r'^https://'
)
...
@@ -488,7 +491,8 @@ class TestContainer(object):
...
@@ -488,7 +491,8 @@ class TestContainer(object):
return
return
# Do not generate 1000 failing tests for not yet updated repos
# Do not generate 1000 failing tests for not yet updated repos
if
schema
!=
'3.0.0'
:
if
schema
!=
'3.0.0'
:
cls
.
_write
(
stream
,
"skipping (schema version
%
s)
\n
"
%
data
[
'schema_version'
])
cls
.
_write
(
stream
,
"skipping (schema version
%
s)
\n
"
%
data
[
'schema_version'
])
return
return
cls
.
_write
(
stream
,
'done
\n
'
)
cls
.
_write
(
stream
,
'done
\n
'
)
...
@@ -562,7 +566,7 @@ class DefaultChannelTests(TestContainer, unittest.TestCase):
...
@@ -562,7 +566,7 @@ class DefaultChannelTests(TestContainer, unittest.TestCase):
@
classmethod
@
classmethod
def
generate_repository_tests
(
cls
,
stream
):
def
generate_repository_tests
(
cls
,
stream
):
if
not
"--test-repositories"
in
userargs
:
if
"--test-repositories"
not
in
userargs
:
# Only generate tests for all repositories (those hosted online)
# Only generate tests for all repositories (those hosted online)
# when run with "--test-repositories" parameter.
# when run with "--test-repositories" parameter.
return
return
...
@@ -591,7 +595,7 @@ class DefaultRepositoryTests(TestContainer, unittest.TestCase):
...
@@ -591,7 +595,7 @@ class DefaultRepositoryTests(TestContainer, unittest.TestCase):
def
test_repository_keys
(
self
):
def
test_repository_keys
(
self
):
keys
=
sorted
(
self
.
j
.
keys
())
keys
=
sorted
(
self
.
j
.
keys
())
self
.
assertEqual
(
keys
,
[
'dependencies'
,
'includes'
,
'packages'
,
self
.
assertEqual
(
keys
,
[
'dependencies'
,
'includes'
,
'packages'
,
'schema_version'
])
'schema_version'
])
self
.
assertEqual
(
self
.
j
[
'schema_version'
],
'3.0.0'
)
self
.
assertEqual
(
self
.
j
[
'schema_version'
],
'3.0.0'
)
self
.
assertEqual
(
self
.
j
[
'packages'
],
[])
self
.
assertEqual
(
self
.
j
[
'packages'
],
[])
...
@@ -636,7 +640,8 @@ class DefaultRepositoryTests(TestContainer, unittest.TestCase):
...
@@ -636,7 +640,8 @@ class DefaultRepositoryTests(TestContainer, unittest.TestCase):
if
'releases'
in
dependency
:
if
'releases'
in
dependency
:
for
release
in
dependency
[
'releases'
]:
for
release
in
dependency
[
'releases'
]:
(
yield
cls
.
_test_dependency_release
,
(
yield
cls
.
_test_dependency_release
,
(
"
%
s (
%
s)"
%
(
dependency_name
,
include
),
release
))
(
"
%
s (
%
s)"
%
(
dependency_name
,
include
),
release
))
def
generate_default_test_methods
(
stream
=
None
):
def
generate_default_test_methods
(
stream
=
None
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment