Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
3c5fa560
Commit
3c5fa560
authored
Jun 05, 2016
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #21916: Added more tests for the turtle module.
Original patch by Jelle Zijlstra.
parent
ed0425c6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
0 deletions
+36
-0
Lib/test/test_turtle.py
Lib/test/test_turtle.py
+36
-0
No files found.
Lib/test/test_turtle.py
View file @
3c5fa560
import
pickle
import
unittest
import
unittest
from
test
import
support
from
test
import
support
...
@@ -129,6 +130,41 @@ class VectorComparisonMixin:
...
@@ -129,6 +130,41 @@ class VectorComparisonMixin:
class
TestVec2D
(
VectorComparisonMixin
,
unittest
.
TestCase
):
class
TestVec2D
(
VectorComparisonMixin
,
unittest
.
TestCase
):
def
test_constructor
(
self
):
vec
=
Vec2D
(
0.5
,
2
)
self
.
assertEqual
(
vec
[
0
],
0.5
)
self
.
assertEqual
(
vec
[
1
],
2
)
self
.
assertIsInstance
(
vec
,
Vec2D
)
self
.
assertRaises
(
TypeError
,
Vec2D
)
self
.
assertRaises
(
TypeError
,
Vec2D
,
0
)
self
.
assertRaises
(
TypeError
,
Vec2D
,
(
0
,
1
))
self
.
assertRaises
(
TypeError
,
Vec2D
,
vec
)
self
.
assertRaises
(
TypeError
,
Vec2D
,
0
,
1
,
2
)
def
test_repr
(
self
):
vec
=
Vec2D
(
0.567
,
1.234
)
self
.
assertEqual
(
repr
(
vec
),
'(0.57,1.23)'
)
def
test_equality
(
self
):
vec1
=
Vec2D
(
0
,
1
)
vec2
=
Vec2D
(
0.0
,
1
)
vec3
=
Vec2D
(
42
,
1
)
self
.
assertEqual
(
vec1
,
vec2
)
self
.
assertEqual
(
vec1
,
tuple
(
vec1
))
self
.
assertEqual
(
tuple
(
vec1
),
vec1
)
self
.
assertNotEqual
(
vec1
,
vec3
)
self
.
assertNotEqual
(
vec2
,
vec3
)
def
test_pickling
(
self
):
vec
=
Vec2D
(
0.5
,
2
)
for
proto
in
range
(
pickle
.
HIGHEST_PROTOCOL
+
1
):
with
self
.
subTest
(
proto
=
proto
):
pickled
=
pickle
.
dumps
(
vec
,
protocol
=
proto
)
unpickled
=
pickle
.
loads
(
pickled
)
self
.
assertEqual
(
unpickled
,
vec
)
self
.
assertIsInstance
(
unpickled
,
Vec2D
)
def
_assert_arithmetic_cases
(
self
,
test_cases
,
lambda_operator
):
def
_assert_arithmetic_cases
(
self
,
test_cases
,
lambda_operator
):
for
test_case
in
test_cases
:
for
test_case
in
test_cases
:
with
self
.
subTest
(
case
=
test_case
):
with
self
.
subTest
(
case
=
test_case
):
...
...
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