You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by br...@apache.org on 2012/12/09 09:05:52 UTC
svn commit: r1418830 - in /subversion/trunk/subversion/bindings/swig: core.i
python/tests/checksum.py python/tests/run_all.py
Author: breser
Date: Sun Dec 9 08:05:51 2012
New Revision: 1418830
URL: http://svn.apache.org/viewvc?rev=1418830&view=rev
Log:
Initial support for svn_checksum.h in SWIG bindings.
* subversion/bindings/swig/core.i: Pulled in header svn_checksum.h
* subversion/bindings/swig/python/tests/checksum.py: New file
* subversion/bindings/swig/python/tests/run_all.py
(suite): Included a test_suite for checksum.py
Patch by: Shivani Poddar <sh...@gmail.com>
(Tweaked by me.)
Suggested by: breser
danielsh
stsp
Added:
subversion/trunk/subversion/bindings/swig/python/tests/checksum.py
Modified:
subversion/trunk/subversion/bindings/swig/core.i
subversion/trunk/subversion/bindings/swig/python/tests/run_all.py
Modified: subversion/trunk/subversion/bindings/swig/core.i
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/swig/core.i?rev=1418830&r1=1418829&r2=1418830&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/swig/core.i (original)
+++ subversion/trunk/subversion/bindings/swig/core.i Sun Dec 9 08:05:51 2012
@@ -786,6 +786,7 @@ svn_swig_pl_set_current_pool (apr_pool_t
%include svn_dirent_uri_h.swg
%include svn_mergeinfo_h.swg
%include svn_io_h.swg
+%include svn_checksum_h.swg
Added: subversion/trunk/subversion/bindings/swig/python/tests/checksum.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/swig/python/tests/checksum.py?rev=1418830&view=auto
==============================================================================
--- subversion/trunk/subversion/bindings/swig/python/tests/checksum.py (added)
+++ subversion/trunk/subversion/bindings/swig/python/tests/checksum.py Sun Dec 9 08:05:51 2012
@@ -0,0 +1,48 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+import unittest, setup_path
+import svn.core
+
+class ChecksumTestCases(unittest.TestCase):
+ def test_checksum(self):
+ # Checking primarily the return type for the svn_checksum_create
+ # function
+ val = svn.core.svn_checksum_create(svn.core.svn_checksum_md5)
+ check_val = svn.core.svn_checksum_to_cstring_display(val)
+
+ # The svn_checksum_to_cstring_display should return a str type object
+ # from the check_val object passed to it
+ if(type(check_val) == str):
+ # The intialized value created from a checksum should be 0
+ if(int(check_val) != 0):
+ self.assertRaises(AssertionError)
+ else:
+ self.assertRaises(TypeError, test_checksum)
+
+def suite():
+ return unittest.defaultTestLoader.loadTestsFromTestCase(ChecksumTestCases)
+if __name__ == '__main__':
+ runner = unittest.TextTestRunner()
+ runner.run(suite())
+
+
+
+
Modified: subversion/trunk/subversion/bindings/swig/python/tests/run_all.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/swig/python/tests/run_all.py?rev=1418830&r1=1418829&r2=1418830&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/swig/python/tests/run_all.py (original)
+++ subversion/trunk/subversion/bindings/swig/python/tests/run_all.py Sun Dec 9 08:05:51 2012
@@ -19,8 +19,8 @@
#
#
import unittest, setup_path
-import mergeinfo, core, client, delta, pool, ra, wc, repository, auth, \
- trac.versioncontrol.tests
+import mergeinfo, core, client, delta, checksum, pool, ra, wc, repository, \
+ auth, trac.versioncontrol.tests
# Run all tests
@@ -28,6 +28,7 @@ def suite():
"""Run all tests"""
s = unittest.TestSuite()
s.addTest(core.suite())
+ s.addTest(checksum.suite())
s.addTest(mergeinfo.suite())
s.addTest(client.suite())
s.addTest(delta.suite())
Re: svn commit: r1418830 - in /subversion/trunk/subversion/bindings/swig: core.i python/tests/checksum.py python/tests/run_all.py
Posted by Daniel Shahaf <da...@apache.org>.
On Sun, Dec 09, 2012 at 08:05:52AM -0000, breser@apache.org wrote:
> +class ChecksumTestCases(unittest.TestCase):
> + def test_checksum(self):
> + # Checking primarily the return type for the svn_checksum_create
> + # function
> + val = svn.core.svn_checksum_create(svn.core.svn_checksum_md5)
> + check_val = svn.core.svn_checksum_to_cstring_display(val)
> +
> + # The svn_checksum_to_cstring_display should return a str type object
> + # from the check_val object passed to it
> + if(type(check_val) == str):
> + # The intialized value created from a checksum should be 0
Typo in comment.
> + if(int(check_val) != 0):
It would be better to write:
if check_val == '0'*32
(except that the test shouldn't hardcode "32")
This will catch a digest of the wrong length, and will avoid doing type
equality checking (inheritance checking is preferred).
> + self.assertRaises(AssertionError)
This line does not cause the test to fail. It returns a context manager ---
the language construct implementing the 'with' statement.
> + else:
> + self.assertRaises(TypeError, test_checksum)
Infinite recursion.
Re: svn commit: r1418830 - in /subversion/trunk/subversion/bindings/swig: core.i python/tests/checksum.py python/tests/run_all.py
Posted by Daniel Shahaf <da...@apache.org>.
On Sun, Dec 09, 2012 at 08:05:52AM -0000, breser@apache.org wrote:
> +class ChecksumTestCases(unittest.TestCase):
> + def test_checksum(self):
> + # Checking primarily the return type for the svn_checksum_create
> + # function
> + val = svn.core.svn_checksum_create(svn.core.svn_checksum_md5)
> + check_val = svn.core.svn_checksum_to_cstring_display(val)
> +
> + # The svn_checksum_to_cstring_display should return a str type object
> + # from the check_val object passed to it
> + if(type(check_val) == str):
> + # The intialized value created from a checksum should be 0
Typo in comment.
> + if(int(check_val) != 0):
It would be better to write:
if check_val == '0'*32
(except that the test shouldn't hardcode "32")
This will catch a digest of the wrong length, and will avoid doing type
equality checking (inheritance checking is preferred).
> + self.assertRaises(AssertionError)
This line does not cause the test to fail. It returns a context manager ---
the language construct implementing the 'with' statement.
> + else:
> + self.assertRaises(TypeError, test_checksum)
Infinite recursion.