/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test__simple_set.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-10-14 07:53:41 UTC
  • mfrom: (4739.3.1 fix-diff-docstring)
  • Revision ID: pqm@pqm.ubuntu.com-20091014075341-xjtgl5ji20autac6
(jml) Bring docstring of bzrlib.diff.get_trees_and_branches_to_diff
        up to date with recent changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2009 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
69
69
        raise RuntimeError('I refuse to play nice')
70
70
 
71
71
 
72
 
class _NoImplementCompare(_Hashable):
73
 
 
74
 
    def __eq__(self, other):
75
 
        return NotImplemented
76
 
 
77
 
 
78
72
# Even though this is an extension, we don't permute the tests for a python
79
73
# version. As the plain python version is just a dict or set
80
 
compiled_simpleset_feature = tests.ModuleAvailableFeature(
81
 
                                'bzrlib._simple_set_pyx')
 
74
 
 
75
class _CompiledSimpleSet(tests.Feature):
 
76
 
 
77
    def _probe(self):
 
78
        if _simple_set_pyx is None:
 
79
            return False
 
80
        return True
 
81
 
 
82
    def feature_name(self):
 
83
        return 'bzrlib._simple_set_pyx'
 
84
 
 
85
CompiledSimpleSet = _CompiledSimpleSet()
82
86
 
83
87
 
84
88
class TestSimpleSet(tests.TestCase):
85
89
 
86
 
    _test_needs_features = [compiled_simpleset_feature]
 
90
    _test_needs_features = [CompiledSimpleSet]
87
91
    module = _simple_set_pyx
88
92
 
89
93
    def assertIn(self, obj, container):
325
329
        # Tries to compare with k1, fails
326
330
        self.assertRaises(RuntimeError, obj.add, k2)
327
331
 
328
 
    def test_richcompare_not_implemented(self):
329
 
        obj = self.module.SimpleSet()
330
 
        # Even though their hashes are the same, tp_richcompare returns
331
 
        # NotImplemented, which means we treat them as not equal
332
 
        k1 = _NoImplementCompare(200)
333
 
        k2 = _NoImplementCompare(200)
334
 
        self.assertLookup(200, '<null>', obj, k1)
335
 
        self.assertLookup(200, '<null>', obj, k2)
336
 
        self.assertIs(k1, obj.add(k1))
337
 
        self.assertLookup(200, k1, obj, k1)
338
 
        self.assertLookup(201, '<null>', obj, k2)
339
 
        self.assertIs(k2, obj.add(k2))
340
 
        self.assertIs(k1, obj[k1])
341
 
 
342
332
    def test_add_and_remove_lots_of_items(self):
343
333
        obj = self.module.SimpleSet()
344
334
        chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890'