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
85ee3e1b
Commit
85ee3e1b
authored
Feb 04, 2010
by
Ezio Melotti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use correct assert* methods in the examples.
parent
28c382f7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
Doc/library/unittest.rst
Doc/library/unittest.rst
+10
-10
No files found.
Doc/library/unittest.rst
View file @
85ee3e1b
...
...
@@ -121,12 +121,12 @@ Here is a short script to test three functions from the :mod:`random` module::
def test_choice(self):
element = random.choice(self.seq)
self.assert
_(element in
self.seq)
self.assert
In(element,
self.seq)
def test_sample(self):
self.assertRaises(ValueError, random.sample, self.seq, 20)
for element in random.sample(self.seq, 5):
self.assert
_(element in
self.seq)
self.assert
In(element,
self.seq)
if __name__ == '__main__':
unittest.main()
...
...
@@ -307,14 +307,14 @@ us when we run the test::
class DefaultWidgetSizeTestCase(SimpleWidgetTestCase):
def runTest(self):
self.assert
True(self.widget.size() ==
(50,50),
'incorrect default size')
self.assert
Equal(self.widget.size(),
(50,50),
'incorrect default size')
class WidgetResizeTestCase(SimpleWidgetTestCase):
def runTest(self):
self.widget.resize(100,150)
self.assert
True(self.widget.size() ==
(100,150),
'wrong size after resize')
self.assert
Equal(self.widget.size(),
(100,150),
'wrong size after resize')
If the :meth:`~TestCase.setUp` method raises an exception while the test is
running, the framework will consider the test to have suffered an error, and the
...
...
@@ -355,13 +355,13 @@ mechanism::
self.widget = None
def testDefaultSize(self):
self.assert
True(self.widget.size() ==
(50,50),
'incorrect default size')
self.assert
Equal(self.widget.size(),
(50,50),
'incorrect default size')
def testResize(self):
self.widget.resize(100,150)
self.assert
True(self.widget.size() ==
(100,150),
'wrong size after resize')
self.assert
Equal(self.widget.size(),
(100,150),
'wrong size after resize')
Here we have not provided a :meth:`~TestCase.runTest` method, but have instead
provided two different test methods. Class instances will now each run one of
...
...
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