diff --git a/unit-testing.html b/unit-testing.html index f9aba84..00efbf6 100755 --- a/unit-testing.html +++ b/unit-testing.html @@ -145,7 +145,7 @@ function to_roman(n):
Execute romantest1.py on the command line to run the test. If you call it with the -v 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:
-you@localhost:~$ python3 romantest1.py -v
+you@localhost:~/diveintopython3/examples$ python3 romantest1.py -v
to_roman should give known result with known input ... FAIL ①
======================================================================
@@ -212,7 +212,7 @@ subtracting 4 from input, adding IV to output
'MCDXXIV'
So the to_roman() function appears to work, at least in this manual spot check. But will it pass the test case you wrote?
-you@localhost:~$ python3 romantest1.py -v +you@localhost:~/diveintopython3/examples$ python3 romantest1.py -v to_roman should give known result with known input ... ok ---------------------------------------------------------------------- @@ -258,7 +258,7 @@ OK
Also note that you’re passing the to_roman() 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 everything in Python is an object?
So what happens when you run the test suite with this new test?
-you@localhost:~$ python3 romantest2.py -v
+you@localhost:~/diveintopython3/examples$ python3 romantest2.py -v
to_roman should give known result with known input ... ok
to_roman should fail with large input ... ERROR ①
@@ -287,7 +287,7 @@ FAILED (errors=1)
Now run the test suite again.
-you@localhost:~$ python3 romantest2.py -v
+you@localhost:~/diveintopython3/examples$ python3 romantest2.py -v
to_roman should give known result with known input ... ok
to_roman should fail with large input ... FAIL ①
@@ -325,7 +325,7 @@ FAILED (failures=1)
Does this make the test pass? Let’s find out.
-you@localhost:~$ python3 romantest2.py -v
+you@localhost:~/diveintopython3/examples$ python3 romantest2.py -v
to_roman should give known result with known input ... ok
to_roman should fail with large input ... ok ①
@@ -374,7 +374,7 @@ OK
Now check that the tests fail:
-you@localhost:~$ python3 romantest3.py -v +you@localhost:~/diveintopython3/examples$ python3 romantest3.py -v 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)
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.
-you@localhost:~$ python3 romantest3.py -v +you@localhost:~/diveintopython3/examples$ python3 romantest3.py -v 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): passNow check that the test fails properly.
-you@localhost:~$ python3 romantest4.py -v +you@localhost:~/diveintopython3/examples$ python3 romantest4.py -v 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)Finally, check that the code does indeed make the test pass.
-you@localhost:~$ python3 romantest4.py -v +you@localhost:~/diveintopython3/examples$ python3 romantest4.py -v 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