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
1ac8a65d
Commit
1ac8a65d
authored
Aug 21, 2014
by
FichteFoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Small edits for tests, no functionality changes
parent
94d086a0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
15 deletions
+19
-15
test.py
tests/test.py
+19
-15
No files found.
tests/test.py
View file @
1ac8a65d
...
@@ -37,9 +37,7 @@ for arg in userargs:
...
@@ -37,9 +37,7 @@ for arg in userargs:
def
_open
(
filepath
,
*
args
,
**
kwargs
):
def
_open
(
filepath
,
*
args
,
**
kwargs
):
"""Wrapper function that can search one dir above if the desired file
"""Wrapper function to search one dir above if a file does not exist."""
does not exist.
"""
if
not
os
.
path
.
exists
(
filepath
):
if
not
os
.
path
.
exists
(
filepath
):
filepath
=
os
.
path
.
join
(
".."
,
filepath
)
filepath
=
os
.
path
.
join
(
".."
,
filepath
)
...
@@ -100,7 +98,7 @@ def generator_class(cls):
...
@@ -100,7 +98,7 @@ def generator_class(cls):
def
get_package_name
(
data
):
def
get_package_name
(
data
):
"""Get
s
"name" from a package with a workaround when it's not defined.
"""Get "name" from a package with a workaround when it's not defined.
Use the last part of details url for the package's name otherwise since
Use the last part of details url for the package's name otherwise since
packages must define one of these two keys anyway.
packages must define one of these two keys anyway.
...
@@ -113,6 +111,7 @@ def get_package_name(data):
...
@@ -113,6 +111,7 @@ def get_package_name(data):
class
TestContainer
(
object
):
class
TestContainer
(
object
):
"""Contains tests that the generators can easily access (when subclassing).
"""Contains tests that the generators can easily access (when subclassing).
Does not contain tests itself, must be used as mixin with unittest.TestCase.
Does not contain tests itself, must be used as mixin with unittest.TestCase.
...
@@ -133,15 +132,19 @@ class TestContainer(object):
...
@@ -133,15 +132,19 @@ class TestContainer(object):
'labels'
:
list
'labels'
:
list
}
}
d_reg
=
r'''^ (https:// github\.com/ [^/]+/ [^/]+ (/tree/ .+ (?<!/)
rel_
d_reg
=
r'''^ (https:// github\.com/ [^/]+/ [^/]+ (/tree/ .+ (?<!/)
|/tags
|/tags
|/)?
|/)?
|https:// bitbucket\.org/ [^/]+/ [^/]+ (/src/ .+ (?<!/)
|https:// bitbucket\.org/ [^/]+/ [^/]+ (/src/ .+ (?<!/)
|\#tags
|\#tags
|/)?
|/)?
) $'''
) $'''
# Strip multilines for better debug info on failures
# Strip multilines for better debug info on failures
details_regex
=
re
.
compile
(
' '
.
join
(
d_reg
.
split
()),
re
.
X
)
rel_d_reg
=
' '
.
join
(
map
(
str
.
strip
,
rel_d_reg
.
split
()))
release_details_regex
=
re
.
compile
(
rel_d_reg
,
re
.
X
)
# Use the same as for releases, for now
package_details_regex
=
release_details_regex
def
_test_repository_keys
(
self
,
include
,
data
):
def
_test_repository_keys
(
self
,
include
,
data
):
self
.
assertTrue
(
2
<=
len
(
data
)
<=
3
,
"Unexpected number of keys"
)
self
.
assertTrue
(
2
<=
len
(
data
)
<=
3
,
"Unexpected number of keys"
)
...
@@ -173,7 +176,8 @@ class TestContainer(object):
...
@@ -173,7 +176,8 @@ class TestContainer(object):
# Check if in the correct file
# Check if in the correct file
for
package_name
in
packages
:
for
package_name
in
packages
:
if
letter
==
'0-9'
:
if
letter
==
'0-9'
:
self
.
assertTrue
(
package_name
[
0
]
.
isdigit
())
self
.
assertTrue
(
package_name
[
0
]
.
isdigit
(),
"Package inserted in wrong file"
)
else
:
else
:
self
.
assertEqual
(
package_name
[
0
]
.
lower
(),
letter
,
self
.
assertEqual
(
package_name
[
0
]
.
lower
(),
letter
,
"Package inserted in wrong file"
)
"Package inserted in wrong file"
)
...
@@ -199,7 +203,7 @@ class TestContainer(object):
...
@@ -199,7 +203,7 @@ class TestContainer(object):
self
.
assertRegex
(
v
,
'^https?://'
)
self
.
assertRegex
(
v
,
'^https?://'
)
elif
k
==
'details'
:
elif
k
==
'details'
:
self
.
assertRegex
(
v
,
self
.
details_regex
,
self
.
assertRegex
(
v
,
self
.
package_
details_regex
,
'The details url is badly formatted or '
'The details url is badly formatted or '
'invalid'
)
'invalid'
)
...
@@ -254,7 +258,7 @@ class TestContainer(object):
...
@@ -254,7 +258,7 @@ class TestContainer(object):
self
.
assertRegex
(
v
,
r'^https?://'
)
self
.
assertRegex
(
v
,
r'^https?://'
)
if
k
==
'details'
:
if
k
==
'details'
:
self
.
assertRegex
(
v
,
self
.
details_regex
,
self
.
assertRegex
(
v
,
self
.
release_
details_regex
,
'The details url is badly formatted or '
'The details url is badly formatted or '
'invalid'
)
'invalid'
)
...
...
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