[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] Improve test cases for svn.wc python bindings

From: Madan U Sreenivasan <madan_at_collab.net>
Date: 2006-06-17 11:24:18 CEST

Hi,

   Pl. find attached some improved tests for svn.wc python bindings.

   This patch is dependant on the import of shutil module which is also
present in a patch I submitted earlier (but not committed, yet)...
        http://subversion.tigris.org/servlets/ReadMsg?list=dev&msgNo=116821
   So, that might have to be taken care of.

   Pl. note that there are two failing test cases, which are supposed to
work as per the svn_wc.h documentation. so, I have kept them as-is (added
comments tho). Am trying to figure out the best way to fix these
issues/documentation and then would come back and fix these failures.

[[[
Improve existing tests for the svn.wc python binding.

* subversion/bindings/swig/python/tests/wc.py
   (global): import shutil.
   (test_check_wc): Add invalid-file case.
   (test_get_ancestry): Add invalid-file case.
   (test_status): Add cases with varying input.
   (test_is_normal_prop): Use failUnless instead of assert_.
   (test_is_wc_prop): Use failUnless instead of assert_.
   (test_is_entry_prop): Use failUnless instead of assert_.
   (test_get_pristine_copy_path): Add test for removal of text-base case.
]]]

Regards,
Madan.

Index: subversion/bindings/swig/python/tests/wc.py
===================================================================
--- subversion/bindings/swig/python/tests/wc.py (revision 20154)
+++ subversion/bindings/swig/python/tests/wc.py (working copy)
@@ -1,4 +1,5 @@
 import unittest, os, tempfile
+import shutil
 
 from svn import core, repos, wc, client
 from libsvn.core import SubversionException
@@ -74,37 +75,70 @@
 
   def test_check_wc(self):
       self.assert_(wc.check_wc(self.path) > 0)
+ self.assertRaises(SubversionException, wc.check_wc,
+ os.path.join(self.path,"NONEXISTANTFILE"))
 
   def test_get_ancestry(self):
       self.assertEqual([self.repos_url, 12],
                        wc.get_ancestry(self.path, self.wc))
+ self.assertRaises(SubversionException,
+ wc.get_ancestry,
+ os.path.join(self.path, "NONEXISTANTFILE"),
+ self.wc)
 
   def test_status(self):
       wc.status2(self.path, self.wc)
 
+ # prepare for tests:remove a versioned file, add an unversioned file
+ removed_versioned_file = os.path.join(self.path, "trunk", "README.txt")
+ unversioned_file = os.path.join(self.path, "UNVERSIONEDFILE")
+ nonexistant_file = os.path.join(self.path, "NONEXISTANTFILE")
+ os.remove(removed_versioned_file)
+ open(unversioned_file, 'w').close()
+
+ # the first case fails now, but is expected to pass as per comment in
+ # subversion/include/svn_wc.h
+ self.assertEqual(wc.status2(removed_versioned_file, self.wc).text_status,
+ wc.svn_wc_status_missing)
+ self.assertEqual(wc.status2(nonexistant_file, self.wc).text_status,
+ wc.svn_wc_status_none)
+ self.assertEqual(wc.status2(unversioned_file, self.wc).text_status,
+ wc.svn_wc_status_unversioned)
+
   def test_is_normal_prop(self):
       self.failIf(wc.is_normal_prop('svn:wc:foo:bar'))
       self.failIf(wc.is_normal_prop('svn:entry:foo:bar'))
- self.assert_(wc.is_normal_prop('svn:foo:bar'))
- self.assert_(wc.is_normal_prop('foreign:foo:bar'))
+ self.failUnless(wc.is_normal_prop('svn:foo:bar'))
+ self.failUnless(wc.is_normal_prop('foreign:foo:bar'))
 
   def test_is_wc_prop(self):
- self.assert_(wc.is_wc_prop('svn:wc:foo:bar'))
+ self.failUnless(wc.is_wc_prop('svn:wc:foo:bar'))
       self.failIf(wc.is_wc_prop('svn:entry:foo:bar'))
       self.failIf(wc.is_wc_prop('svn:foo:bar'))
       self.failIf(wc.is_wc_prop('foreign:foo:bar'))
 
   def test_is_entry_prop(self):
- self.assert_(wc.is_entry_prop('svn:entry:foo:bar'))
+ self.failUnless(wc.is_entry_prop('svn:entry:foo:bar'))
       self.failIf(wc.is_entry_prop('svn:wc:foo:bar'))
       self.failIf(wc.is_entry_prop('svn:foo:bar'))
       self.failIf(wc.is_entry_prop('foreign:foo:bar'))
 
   def test_get_pristine_copy_path(self):
+ text_base = os.path.join(self.path, wc.get_adm_dir(), 'text-base')
       self.assertEqual(
         wc.get_pristine_copy_path(os.path.join(self.path, 'foo')),
- os.path.join(self.path, wc.get_adm_dir(), 'text-base', 'foo.svn-base'))
+ os.path.join(text_base, 'foo.svn-base'))
 
+ # now remove the text-base and test
+ # As of now, this fails, but should pass as per
+ # comment in subversion/include/svn_wc.h
+ if os.path.exists(text_base):
+ shutil.rmtree(text_base)
+
+ self.assertEqual(
+ wc.get_pristine_copy_path(os.path.join(self.path, 'NONEXISTANTFILE')),
+ None)
+
   def tearDown(self):
       wc.adm_close(self.wc)
 

Improve existing tests for the svn.wc python binding.

* subversion/bindings/swig/python/tests/wc.py
  (global): import shutil.
  (test_check_wc): Add invalid-file case.
  (test_get_ancestry): Add invalid-file case.
  (test_status): Add cases with varying input.
  (test_is_normal_prop): Use failUnless instead of assert_.
  (test_is_wc_prop): Use failUnless instead of assert_.
  (test_is_entry_prop): Use failUnless instead of assert_.
  (test_get_pristine_copy_path): Add test for removal of text-base case.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Jun 17 10:54:02 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.