mirror of
https://github.com/kennethreitz/dive-into-python3.git
synced 2026-06-05 23:10:17 +00:00
be more clear about current working directory
This commit is contained in:
+9
-9
@@ -145,7 +145,7 @@ function to_roman(n):
|
||||
</ol>
|
||||
<p>Execute <code>romantest1.py</code> on the command line to run the test. If you call it with the <code>-v</code> command-line option, it will give more verbose output so you can see exactly what’s going on as each test case runs. With any luck, your output should look like this:
|
||||
<pre class=screen>
|
||||
<samp class=p>you@localhost:~$ </samp><kbd>python3 romantest1.py -v</kbd>
|
||||
<samp class=p>you@localhost:~/diveintopython3/examples$ </samp><kbd>python3 romantest1.py -v</kbd>
|
||||
<samp><a>to_roman should give known result with known input ... FAIL <span class=u>①</span></a>
|
||||
|
||||
======================================================================
|
||||
@@ -212,7 +212,7 @@ subtracting 4 from input, adding IV to output
|
||||
'MCDXXIV'</samp></pre>
|
||||
<p>So the <code>to_roman()</code> function appears to work, at least in this manual spot check. But will it pass the test case you wrote?
|
||||
<pre class='nd screen'>
|
||||
<samp class=p>you@localhost:~$ </samp><kbd>python3 romantest1.py -v</kbd>
|
||||
<samp class=p>you@localhost:~/diveintopython3/examples$ </samp><kbd>python3 romantest1.py -v</kbd>
|
||||
<samp>to_roman should give known result with known input ... ok
|
||||
|
||||
----------------------------------------------------------------------
|
||||
@@ -258,7 +258,7 @@ OK</samp></pre>
|
||||
<p>Also note that you’re passing the <code>to_roman()</code> function itself as an argument; you’re not calling it, and you’re not passing the name of it as a string. Have I mentioned recently how handy it is that <a href=your-first-python-program.html#everythingisanobject>everything in Python is an object</a>?
|
||||
<p>So what happens when you run the test suite with this new test?
|
||||
<pre class=screen>
|
||||
<samp class=p>you@localhost:~$ </samp><kbd>python3 romantest2.py -v</kbd>
|
||||
<samp class=p>you@localhost:~/diveintopython3/examples$ </samp><kbd>python3 romantest2.py -v</kbd>
|
||||
<samp>to_roman should give known result with known input ... ok
|
||||
<a>to_roman should fail with large input ... ERROR <span class=u>①</span></a>
|
||||
|
||||
@@ -287,7 +287,7 @@ FAILED (errors=1)</samp></pre>
|
||||
</ol>
|
||||
<p>Now run the test suite again.
|
||||
<pre class=screen>
|
||||
<samp class=p>you@localhost:~$ </samp><kbd>python3 romantest2.py -v</kbd>
|
||||
<samp class=p>you@localhost:~/diveintopython3/examples$ </samp><kbd>python3 romantest2.py -v</kbd>
|
||||
<samp>to_roman should give known result with known input ... ok
|
||||
<a>to_roman should fail with large input ... FAIL <span class=u>①</span></a>
|
||||
|
||||
@@ -325,7 +325,7 @@ FAILED (failures=1)</samp></pre>
|
||||
</ol>
|
||||
<p>Does this make the test pass? Let’s find out.
|
||||
<pre class=screen>
|
||||
<samp class=p>you@localhost:~$ </samp><kbd>python3 romantest2.py -v</kbd>
|
||||
<samp class=p>you@localhost:~/diveintopython3/examples$ </samp><kbd>python3 romantest2.py -v</kbd>
|
||||
<samp>to_roman should give known result with known input ... ok
|
||||
<a>to_roman should fail with large input ... ok <span class=u>①</span></a>
|
||||
|
||||
@@ -374,7 +374,7 @@ OK</samp></pre>
|
||||
<p>Now check that the tests fail:
|
||||
|
||||
<pre class='nd screen'>
|
||||
<samp class=p>you@localhost:~$ </samp><kbd>python3 romantest3.py -v</kbd>
|
||||
<samp class=p>you@localhost:~/diveintopython3/examples$ </samp><kbd>python3 romantest3.py -v</kbd>
|
||||
<samp>to_roman should give known result with known input ... ok
|
||||
to_roman should fail with negative input ... FAIL
|
||||
to_roman should fail with large input ... ok
|
||||
@@ -423,7 +423,7 @@ FAILED (failures=2)</samp></pre>
|
||||
<p>I could show you a whole series of unrelated examples to show that the multiple-comparisons-at-once shortcut works, but instead I’ll just run the unit tests and prove it.
|
||||
|
||||
<pre class='nd screen'>
|
||||
<samp class=p>you@localhost:~$ </samp><kbd>python3 romantest3.py -v</kbd>
|
||||
<samp class=p>you@localhost:~/diveintopython3/examples$ </samp><kbd>python3 romantest3.py -v</kbd>
|
||||
<samp>to_roman should give known result with known input ... ok
|
||||
to_roman should fail with negative input ... ok
|
||||
to_roman should fail with large input ... ok
|
||||
@@ -470,7 +470,7 @@ class OutOfRangeError(ValueError): pass
|
||||
<p>Now check that the test fails properly.
|
||||
|
||||
<pre class='nd screen'>
|
||||
<samp class=p>you@localhost:~$ </samp><kbd>python3 romantest4.py -v</kbd>
|
||||
<samp class=p>you@localhost:~/diveintopython3/examples$ </samp><kbd>python3 romantest4.py -v</kbd>
|
||||
<samp>to_roman should give known result with known input ... ok
|
||||
to_roman should fail with negative input ... ok
|
||||
to_roman should fail with non-integer input ... FAIL
|
||||
@@ -513,7 +513,7 @@ FAILED (failures=1)</samp></pre>
|
||||
<p>Finally, check that the code does indeed make the test pass.
|
||||
|
||||
<pre class='nd screen'>
|
||||
<samp class=p>you@localhost:~$ </samp><kbd>python3 romantest4.py -v</kbd>
|
||||
<samp class=p>you@localhost:~/diveintopython3/examples$ </samp><kbd>python3 romantest4.py -v</kbd>
|
||||
<samp>to_roman should give known result with known input ... ok
|
||||
to_roman should fail with negative input ... ok
|
||||
to_roman should fail with non-integer input ... ok
|
||||
|
||||
Reference in New Issue
Block a user