Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
grumpy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
grumpy
Commits
86550b27
Commit
86550b27
authored
Jan 21, 2017
by
YOU
Committed by
Dylan Trotter
Jan 20, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add stdlib string tests (#181)
parent
a09bb560
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
1913 additions
and
31 deletions
+1913
-31
Makefile
Makefile
+4
-0
third_party/stdlib/string.py
third_party/stdlib/string.py
+34
-23
third_party/stdlib/test/string_tests.py
third_party/stdlib/test/string_tests.py
+1417
-0
third_party/stdlib/test/test_dict.py
third_party/stdlib/test/test_dict.py
+1
-6
third_party/stdlib/test/test_string.py
third_party/stdlib/test/test_string.py
+455
-0
third_party/stdlib/test/test_support.py
third_party/stdlib/test/test_support.py
+1
-1
third_party/stdlib/types.py
third_party/stdlib/types.py
+1
-1
No files found.
Makefile
View file @
86550b27
...
...
@@ -80,6 +80,10 @@ STDLIB_TESTS := \
tempfile_test
\
test
/seq_tests
\
test
/test_tuple
\
test
/mapping_tests
\
test
/test_dict
\
test
/string_tests
\
test
/test_string
\
threading_test
\
time_test
\
types_test
\
...
...
third_party/stdlib/string.py
View file @
86550b27
...
...
@@ -82,7 +82,7 @@ def maketrans(fromstr, tostr):
####################################################################
#
import re as _re
import re as _re
class _multimap(object):
"""
Helper
class
for
combining
multiple
mappings
.
...
...
@@ -101,36 +101,47 @@ class _multimap(object):
return self._secondary[key]
# class _TemplateMetaclass(type):
# pattern = r"""
# %(delim)s(?:
# (?P<escaped>%(delim)s) | # Escape sequence of two delimiters
# (?P<named>%(id)s) | # delimiter and a Python identifier
# {(?P<braced>%(id)s)} | # delimiter and a braced identifier
# (?P<invalid>) # Other ill-formed delimiter exprs
# )
# """
# def __init__(cls, name, bases, dct):
# super(_TemplateMetaclass, cls).__init__(name, bases, dct)
# if 'pattern' in dct:
# pattern = cls.pattern
# else:
# pattern = _TemplateMetaclass.pattern % {
# 'delim' : _re.escape(cls.delimiter),
# 'id' : cls.idpattern,
# }
# cls.pattern = _re.compile(pattern, _re.IGNORECASE | _re.VERBOSE)
class _TemplateMetaclass(type):
# pattern = r"""
# %(delim)s(?:
# (?P<escaped>%(delim)s) | # Escape sequence of two delimiters
# (?P<named>%(id)s) | # delimiter and a Python identifier
# {(?P<braced>%(id)s)} | # delimiter and a braced identifier
# (?P<invalid>) # Other ill-formed delimiter exprs
# )
# """
pattern
=
r"""
%s(?:
(?P<escaped>%s) | # Escape sequence of two delimiters
(?P<named>%s) | # delimiter and a Python identifier
{(?P<braced>%s)} | # delimiter and a braced identifier
(?P<invalid>) # Other ill-formed delimiter exprs
)
"""
def
__init__
(
cls
,
name
,
bases
,
dct
):
# super(_TemplateMetaclass, cls).__init__(name, bases, dct)
super
(
_TemplateMetaclass
,
cls
)
if
'pattern'
in
dct
:
pattern
=
cls
.
pattern
else
:
# pattern = _TemplateMetaclass.pattern % {
# 'delim' : _re.escape(cls.delimiter),
# 'id' : cls.idpattern,
# }
cls_delim
,
cls_id
=
_re
.
escape
(
cls
.
delimiter
),
cls
.
idpattern
pattern
=
_TemplateMetaclass
.
pattern
%
(
cls_delim
,
cls_delim
,
cls_id
,
cls_id
)
cls
.
pattern
=
_re
.
compile
(
pattern
,
_re
.
IGNORECASE
|
_re
.
VERBOSE
)
class
Template
(
object
):
"""A string class for supporting $-substitutions."""
#
__metaclass__ = _TemplateMetaclass
__metaclass__
=
_TemplateMetaclass
delimiter
=
'$'
idpattern
=
r'[_a-z][_a-z0-9]*'
def
__init__
(
self
,
template
):
def
__init__
(
self
,
template
,
*
arg
):
self
.
template
=
template
# Search for $$, $identifier, ${identifier}, and any bare $'s
...
...
third_party/stdlib/test/string_tests.py
0 → 100644
View file @
86550b27
This diff is collapsed.
Click to expand it.
third_party/stdlib/test/test_dict.py
View file @
86550b27
...
...
@@ -42,7 +42,6 @@ class DictTest(unittest.TestCase):
self
.
assertTrue
(
d
.
has_key
(
'b'
))
self
.
assertRaises
(
TypeError
,
d
.
keys
,
None
)
@
unittest
.
expectedFailure
def
test_values
(
self
):
d
=
{}
self
.
assertEqual
(
d
.
values
(),
[])
...
...
@@ -727,8 +726,4 @@ def test_main():
)
if
__name__
==
"__main__"
:
import
traceback
try
:
test_main
()
except
:
traceback
.
print_exc
()
test_main
()
third_party/stdlib/test/test_string.py
0 → 100644
View file @
86550b27
This diff is collapsed.
Click to expand it.
third_party/stdlib/test/test_support.py
View file @
86550b27
...
...
@@ -1273,7 +1273,7 @@ def check_py3k_warnings(*filters, **kwargs):
# _2G = 2 * _1G
# _4G = 4 * _1G
#
MAX_Py_ssize_t = sys.maxsize
MAX_Py_ssize_t
=
sys
.
maxsize
# def set_memlimit(limit):
# global max_memuse
...
...
third_party/stdlib/types.py
View file @
86550b27
...
...
@@ -50,7 +50,7 @@ GeneratorType = type(_g())
class
_C
(
object
):
def
_m
(
self
):
pass
#
ClassType = type(_C)
ClassType
=
type
(
_C
)
UnboundMethodType
=
type
(
_C
.
_m
)
# Same as MethodType
_x
=
_C
()
#InstanceType = type(_x)
...
...
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