frank: thuban/test test_load.py,1.41,1.42

Bernhard Herzog bh at intevation.de
Thu Dec 16 14:16:44 CET 2004


Frank Koormann <frank.koormann at intevation.de> writes:

> What else should I check? The point is, the session defined for the test
> is broken, the path to roads_line.shp is wrong. The current
> approach is "all or nothing", i.e. you can't cancel loading for a
> missing shapefile but load all others. The existance of a session
> with three layers is the pointer that the loading has been successfully.
> And it couldn't be successfully without interpreting the callbacks
> correct:

The callbacks behave differently in all three test cases.  If the
differences are not observable, what's the point?

> What I test is open_shapefile():
>
> test_01_single_path_error_fix:
[...]
> test_02_path_error_fix_from_list:
[...]

This information could be added to the test cases as doc-strings or
comments.

> What could be added is something like already implemented in
> test_06_path_error_fix_from_list_fails
> to ensure that all reactions defined for the callback actually have been 
> used:
>         self.assertRaises(IndexError, s_cb.s_cb, None, "search")
>         self.assertRaises(IndexError, s_cb.s_cb, None, "check")
> --> pop on an empty list should cause an IndexError

I think its better to more explicit.  You could for instance record the
parameters with which the callback was called and check that at the end.
See this patch for an example:

*** test_load.py.~1.43.~	Wed Dec 15 11:02:38 2004
--- test_load.py	Thu Dec 16 14:15:30 2004
***************
*** 992,1000 ****
--- 992,1002 ----
          """
  
          self.params = params
+         self.calls = []
  
  
      def s_cb(self, filename, mode = None, second_try= 0):
+         self.calls.append((filename, mode, second_try))
          if self.params.has_key(mode):
              return self.params[mode].pop(0)
          else:
***************
*** 1052,1057 ****
--- 1054,1065 ----
          self.session = load_session(self.filename(), 
                                      shapefile_callback =s_cb.s_cb)
          self.checkSession(self.session)
+         self.assertEquals(s_cb.calls,
+                           [(os.path.abspath(os.path.join(self.temp_dir(),
+                                                          "..", "Data",
+                                                          "iceland",
+                                                          "roads-line.shp")),
+                             'search', 0)])
          
      def test_02_path_error_fix_from_list(self):
          """Test single file path error fix."""


>> Plus, you do this test as the only actual check in three test cases.
>> That looks fishy to me.  Those three test cases use callbacks that do
>> differ in what they return.  Doesn't that lead to some observable
>> differences in behavior that you can test for?
>
> No, as explained above.

Whether and how the callback is called is an observable difference.


   Bernhard

-- 
Intevation GmbH                                 http://intevation.de/
Skencil                                           http://skencil.org/
Thuban                                  http://thuban.intevation.org/




More information about the Thuban-devel mailing list

This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)