How to use the testfixtures.compare function in testfixtures

To help you get started, we’ve selected a few testfixtures examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github giantas / sorter / tests / testsoperations.py View on Github external
dir_2 = self.temp.makedir('three/two')
        self.temp.makedir('one/two/new whatsapp images folder')
        self.add_files_to_path(dir_1, 'many')
        self.operations.src = dir_1
        self.operations.group = False
        self.operations.recursive = False
        with self.subTest(1):
            compare(os.path.join(self.tempdir, 'one', 'two'), dir_1)
        kwargs = {
            'search_string': 'whatsapp image',
            'group': True,
            'recursive': False,
        }
        db_ready = self.db_helper.initialise_db(test=True)
        with self.subTest(3):
            compare(True, db_ready)
        with self.subTest(4):
            compare(True, os.path.exists(self.db_helper.DB_NAME))
        self.operations.start(src=dir_1, dst=dir_2,
                              send_message=messenger, **kwargs)
        with self.subTest(5):
            self.temp.compare([
                '{}/'.format('whatsapp image'),
                '{}/{}/'.format('whatsapp image',
                                'new whatsapp images folder'),
                '{}/{}'.format('whatsapp image',
                               'WhatsApp Image 2017-06-10 at 9.53.02 PM.jpeg'),
                '{}/{}'.format('whatsapp image',
                               'WhatsApp Image 2017-06-05 at 09.19.55.jpeg'),
                '{}/{}'.format('whatsapp image',
                               'WhatsApp Image 2017-06-14 at 2.26.53 PM.jpeg'),
                '{}/{}'.format('whatsapp image', 'GBWhatsApp Images.zip'),
github Simplistix / configurator / tests / test_node.py View on Github external
def test_node_not_there_create(self):
        root = ConfigNode()
        child = root.node('a.b.c', create=True)
        compare(root.data, expected={'a': {'b': {'c': {}}}})
        child.set(1)
        compare(root.data, expected={'a': {'b': {'c': 1}}})
github Simplistix / picky-conda / tests / test_functional.py View on Github external
'--conda-versions', conda_versions,
                            '--update'],
                      output="""\
b 4.1 missing from requirements.txt
c 1.0 missing from conda-versions.txt
d 5 missing from conda-versions.txt
Updating '{0}'
Updating '{1}'
""".format(requirements, conda_versions),
                      return_code=1)
        compare(b"""\
# picky added the following on 2001-01-02 03:04:05:
b==4.1
""", self.dir.read('requirements.txt'))

        compare(b"""\
# picky added the following on 2001-01-02 03:04:05:
c=1.0
d=5
""", self.dir.read('conda-versions.txt'))
github Simplistix / configurator / tests / test_config.py View on Github external
def test_nested_working(self):
        config1 = Config(dict(x=1, y=[2, 3], z=dict(a=4, b=5)))
        config2 = Config(dict(w=6, y=[7], z=dict(b=8, c=9)))
        config1.merge(config2)

        compare(config1.data,
                expected=dict(x=1, w=6, y=[2, 3, 7], z=dict(a=4, b=8, c=9)))
github giantas / sorter / tests / testsdir.py View on Github external
def test_fails_if_basename_not_equal(self):
        """Return False if file names do not match."""
        compare(os.path.basename(self.tempdir.path), self.dir.name)
github giantas / sorter / tests / testsdir / testsdirectory.py View on Github external
def test_returns_false_if_pathlib_methods_fail(self):
        with self.subTest(1):
            path = self.tempdir.makedir('abc/fig/last')
            d = Directory(path)
            compare('', d.suffix)
            compare('last', d.stem)

        with self.subTest(2):
            path = self.tempdir.makedir('abc/fig/my awesome cat.txt')
            d = Directory(path)
            compare('.txt', d.suffix)
            compare('my awesome cat', d.stem)
github Simplistix / picky-conda / tests / test_main.py View on Github external
def test_lock_with_config(tmpdir):
    tmpdir.join('picky.yaml').write(sample_config)
    rc = run(['lock'])
    compare(rc, expected=None)
    compare(tmpdir.join('environment.lock.yaml').read(),
            expected=serialized_after_config)
github Simplistix / configurator / tests / test_config.py View on Github external
def test_mapping_paths(self):
        config = Config({'x': 'old'})
        data = {'foo': 'bar'}
        config.merge(data, mapping={
            source['foo']: target['x']
        })
        compare(config.data, expected={'x': 'bar'})
github Simplistix / configurator / tests / test_mapping.py View on Github external
def test_attr(self):
        data = Namespace(x=1)
        store(data, target.x, 2)
        compare(data.x, 2)
github Simplistix / picky-conda / tests / test_env.py View on Github external
def test_to_string(self):
        compare(sample_env.to_string(),
                expected=sample_serialized)