Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8183863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:18:03+00:00 2026-06-07T01:18:03+00:00

I am working on a Python module that suppose to checkout some code from

  • 0

I am working on a Python module that suppose to checkout some code from SVN and build it. After much refactoring of some legacy code, I got a fairly decent coverage of the code, however, I have a gaping hole in the code that uses pysvn.

Admittedly the concept of Mock object is new to me, but after reading some of the documentation of MiniMock and pymox (both are available in my environment), I came to the conclusion that I will need to capture some pysvn output and have it returned in my test code.

But here I find myself (pardon the pun) in a pickle. The objects returned from the pysvn.Client() commands do not behave nicely when I try to pickle them, or even to compare them.

Any suggestion of how to serialize or otherwise mock pysvn or some other non-pythonic behaving objects?

Naturally, I am willing to accept that I am approaching this problem from the wrong direction, or that I am simply an idiot. In that case any advice will be helpful.

Additional information 0:

Some pysvn object can be reduced to a dict by accessing their data property, and can be reproduced by passing this dict into the appropriate __init__()

For example:

>>> svn=pysvn.Client()
>>> svn.list('http://svn/svn/')[0][0]
<PysvnList u'http://svn/svn'>
>>> d=svn.list('http://svn/svn/')[0][0].data
>>> pysvn.PysvnList(d)
<PysvnList u'http://svn/svn'>

However inside this object there might be some unpicklable objects:

>>> cPickle.dumps(d)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
cPickle.UnpickleableError: Cannot pickle <type 'node_kind'> objects

Additional Information 1:

As for @H. Dunlop request, here is a (simplified) snippet of my code,
It allow to get a list out of SVN, and let the user choose an item from that list:

class Menu(object):
    """a well covered class"""
    # ...

class VersionControl(object):
    """A poorly covered class"""

    def __init__(self):
        self.svn = pysvn.Client()

    # ...

    def list(self, url):
        """svn ls $url"""
        return [os.path.basename(x['path']) for (x,_) in self.svn.list(url)[1:]]

    def choose(self, choice, url):
        """Displays a menu from svn list, and get's the users choice form it.

        Returns the svn item (path).
        """
        menu = Menu(prompt="Please choose %s from list:\n" % choice,
                    items=self.list(url),
                    muliple_choice=False)
        menu.present()
        return menu.chosen()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T01:18:04+00:00Added an answer on June 7, 2026 at 1:18 am

    In this answer I used minimock, I’m not actually that familiar with it and would suggest using http://www.voidspace.org.uk/python/mock/ instead. This code would end up a bit cleaner . But you specified minimock or pymox so here goes:

    from minimock import TraceTracker, Mock, mock
    import unittest
    
    import pysvn
    
    from code_under_test import VersionControl
    
    
    class TestVersionControl(unittest.TestCase):
    
    
        def test_init(self):
    
            mock_svn = Mock(name='svn_client')
            mock('pysvn.Client', returns=mock_svn)
    
            vc = VersionControl()
    
            self.assertEqual(vc.svn, mock_svn)
    
    
        def test_list_calls_svn_list_and_returns_urls(self):
    
            tracker = TraceTracker()
            test_url = 'a test_url'
            mock_data = [
                ({'path': 'first result excluded'}, None),
                ({'path': 'url2'}, None),
                ({'path': 'url3', 'info': 'not in result'}, None),
                ({'path': 'url4'}, None),
            ]
    
            vc = VersionControl()
            mock('vc.svn.list', returns=mock_data, tracker=tracker)
    
            response = vc.list(test_url)
            self.assertEqual(['url2', 'url3', 'url4'], response)
            self.assertTrue("Called vc.svn.list('a test_url')" in tracker.dump())
    
    
    if __name__ == '__main__':
        unittest.main()
    

    If you wanted to test more of the underlying dictionary returned by pysvn then you can just modify the list of tuples with dictionaries inside of it that you make it return. You could even write a little bit of code that just dumped out the dictionaries from the pysvn objects .

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im currently working on a Python/Pygame module to wrap some basic sprite animation. Animation
I'm working on a Python module that is acting as an interpreter for an
I'm trying to get the argparse module working in Python. My problem is that
PEP 8 says that Python package and module names should be short, since some
I'm working on a Python C extension module (for CPython 2.5). It calls some
I'm working with Python's Mechanize module. I've come across 3 different sites that cannot
I wanted to use winreg module of python for working with windows registry. But
I am currently working with Python and have been confused over the fact that
now I am working with python. So one question about dict .... suppose I
I am working with python plugins.I used list to store some values as below:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.