Did I find the right examples for you? yes no

All Samples(615)  |  Call(615)  |  Derive(0)  |  Import(0)
Use fixture in a test case.

The fixture will be setUp, and self.addCleanup(fixture.cleanUp) called.

:param fixture: The fixture to use.
:return: The fixture, after setting it up and scheduling a cleanup for
   it.

src/o/s/os-collect-config-0.1.17/os_collect_config/tests/test_collect.py   os-collect-config(Download)
    def setUp(self):
        super(TestCollect, self).setUp()
        self.useFixture(fixtures.FakeLogger())
        self.addCleanup(cfg.CONF.reset)
 
            calls.append(proc_args)
            return dict(returncode=0)
        self.useFixture(fixtures.FakePopen(capture_popen))
        self._call_main(occ_args)
        return calls
 
    def test_main(self):
        expected_cmd = self.getUniqueString()
        cache_dir = self.useFixture(fixtures.TempDir())
        backup_cache_dir = self.useFixture(fixtures.TempDir())
    def test_main_force_command(self):
        cache_dir = self.useFixture(fixtures.TempDir())
        backup_cache_dir = self.useFixture(fixtures.TempDir())
        fake_metadata = _setup_local_metadata(self)
        occ_args = [

src/h/e/heat-cfntools-1.2.7/heat_cfntools/tests/test_cfn_helper.py   heat-cfntools(Download)
    def setUp(self):
        super(TestMetadataRetrieve, self).setUp()
        self.tdir = self.useFixture(fixtures.TempDir())
        self.last_file = os.path.join(self.tdir.path, 'last_metadata')
 
        self.assertIsNone(md._metadata)
 
        displayed = self.useFixture(fixtures.StringStream('stdout'))
        fake_stdout = displayed.stream
        self.useFixture(fixtures.MonkeyPatch('sys.stdout', fake_stdout))
        self.assertEqual(md_str, str(md))
 
        displayed = self.useFixture(fixtures.StringStream('stdout'))
        fake_stdout = displayed.stream
        self.useFixture(fixtures.MonkeyPatch('sys.stdout', fake_stdout))

src/o/p/opencenter-agent-HEAD/tests/test_agent.py   opencenter-agent(Download)
    def test_exit_no_exception(self):
        self.exit_code_set = None
        self.useFixture(fixtures.MonkeyPatch('sys.exit', self.fake_exit))
 
        agent = OpenCenterAgentNoInitialization([])
    def test_exit_exception(self):
        self.exit_code_set = None
        self.useFixture(fixtures.MonkeyPatch('sys.exit', self.fake_exit))
 
        agent = OpenCenterAgentNoInitialization([])
    def test_usage(self):
        io = StringIO.StringIO()
        self.useFixture(fixtures.MonkeyPatch('sys.stdout', io))
 
        agent = OpenCenterAgentNoInitialization([])
    def test_parse_opts_bad_arg(self):
        io = StringIO.StringIO()
        self.useFixture(fixtures.MonkeyPatch('sys.stdout', io))
 
        self.exit_code_set = None
        self.useFixture(fixtures.MonkeyPatch('sys.exit', self.fake_exit))

src/p/k/pkgme-devportal-0.5.1/devportalbinary/acceptance/tests/__init__.py   pkgme-devportal(Download)
    def test_empty(self):
        """Should fail for a project with no binaries."""
        test_data = self.useFixture(TestData("empty"))
        self.assertRaises(NoEligibleBackend, run_pkgme, test_data)
 
    def test_python(self):
        """Should fail for a Python project."""
        test_data = self.useFixture(TestData("python"))
    def test_gtk(self):
        """Runs successfully for a basic GTK+ application."""
        self.useFixture(
            LibdepFixture(
                [("libpthread0", {'i386': {"libpthread.so.0": "libpthread0"}}),
                 ("libc6", {'i386': {"libc.so.6": "libc6"}})]))
        test_data = self.useFixture(TestData("gtk"))
    def test_bundled_library(self):
        """Runs successfully for a basic bundled libary."""
        self.useFixture(
            LibdepFixture([("libc6", {'i386': {"libc.so.6": "libc6"}})]))
        test_data = self.useFixture(TestData("bundled_lib"))

src/t/e/testtools-0.9.35/testtools/tests/test_run.py   testtools(Download)
    def test_run_custom_list(self):
        self.useFixture(SampleTestFixture())
        tests = []
        class CaptureList(run.TestToolsTestRunner):
            def list(self, test):
    def test_run_list(self):
        self.useFixture(SampleTestFixture())
        out = StringIO()
        try:
            run.main(['prog', '-l', 'testtools.runexample.test_suite'], out)
    def test_run_list_failed_import(self):
        if not run.have_discover:
            self.skipTest("Need discover")
        broken = self.useFixture(SampleTestFixture(broken=True))
        out = StringIO()
    def test_run_orders_tests(self):
        self.useFixture(SampleTestFixture())
        out = StringIO()
        # We load two tests - one that exists and one that doesn't, and we
        # should get the one that exists and neither the one that doesn't nor
        # the unmentioned one that does.
        tempdir = self.useFixture(fixtures.TempDir())

src/t/e/testtools-HEAD/testtools/tests/test_run.py   testtools(Download)
    def test_run_custom_list(self):
        self.useFixture(SampleTestFixture())
        tests = []
        class CaptureList(run.TestToolsTestRunner):
            def list(self, test):
    def test_run_list(self):
        self.useFixture(SampleTestFixture())
        out = StringIO()
        try:
            run.main(['prog', '-l', 'testtools.runexample.test_suite'], out)
    def test_run_list_failed_import(self):
        if not run.have_discover:
            self.skipTest("Need discover")
        broken = self.useFixture(SampleTestFixture(broken=True))
        out = StringIO()
    def test_run_orders_tests(self):
        self.useFixture(SampleTestFixture())
        out = StringIO()
        # We load two tests - one that exists and one that doesn't, and we
        # should get the one that exists and neither the one that doesn't nor
        # the unmentioned one that does.
        tempdir = self.useFixture(fixtures.TempDir())

src/t/e/testtools-0.9.35/testtools/tests/test_fixturesupport.py   testtools(Download)
            def test_foo(self):
                self.useFixture(fixture)
        result = unittest.TestResult()
        SimpleTest('test_foo').run(result)
        self.assertTrue(result.wasSuccessful())
            def test_foo(self):
                self.useFixture(fixture)
        result = unittest.TestResult()
        SimpleTest('test_foo').run(result)
        self.assertFalse(result.wasSuccessful())
            def test_foo(self):
                self.useFixture(fixture)
                # Add a colliding detail (both should show up)
                self.addDetail('content',
                    content.Content(content_type.UTF8_TEXT, lambda:[_b('foo')]))
            def test_foo(self):
                self.useFixture(fixture)
        result = ExtendedTestResult()
        SimpleTest('test_foo').run(result)
        self.assertEqual('addSuccess', result._events[-2][0])
            def test_foo(self):
                self.useFixture(fixture)
        result = ExtendedTestResult()
        SimpleTest('test_foo').run(result)
        self.assertEqual('addError', result._events[-2][0])

src/t/e/testtools-HEAD/testtools/tests/test_fixturesupport.py   testtools(Download)
            def test_foo(self):
                self.useFixture(fixture)
        result = unittest.TestResult()
        SimpleTest('test_foo').run(result)
        self.assertTrue(result.wasSuccessful())
            def test_foo(self):
                self.useFixture(fixture)
        result = unittest.TestResult()
        SimpleTest('test_foo').run(result)
        self.assertFalse(result.wasSuccessful())
            def test_foo(self):
                self.useFixture(fixture)
                # Add a colliding detail (both should show up)
                self.addDetail('content',
                    content.Content(content_type.UTF8_TEXT, lambda:[_b('foo')]))
            def test_foo(self):
                self.useFixture(fixture)
        result = ExtendedTestResult()
        SimpleTest('test_foo').run(result)
        self.assertEqual('addSuccess', result._events[-2][0])
            def test_foo(self):
                self.useFixture(fixture)
        result = ExtendedTestResult()
        SimpleTest('test_foo').run(result)
        self.assertEqual('addError', result._events[-2][0])

src/p/k/pkgme-devportal-0.5.1/devportalbinary/tests/test_unity_webapps.py   pkgme-devportal(Download)
        filename = self.getUniqueString() + ".user.js"
        tree[filename] = {}
        tempdir = self.useFixture(FileTree(tree))
        self.assertEqual(20, UnityWebappsBackend.want(tempdir.path)['score'])
 
    def test_want_with_no_metadata(self):
        # If we detect no metadata file we score 0
        filename = self.getUniqueString() + ".user.js"
        tree = {filename: {}}
        tempdir = self.useFixture(FileTree(tree))
    def test_want_with_no_userscript(self):
        # If we detect no userscript file we score 0
        tree = self.get_metadata_tree()
        tempdir = self.useFixture(FileTree(tree))
        want = UnityWebappsBackend.want(tempdir.path)
        filename = self.getUniqueString() + ".something"
        tree[filename] = {}
        tempdir = self.useFixture(FileTree(tree))
        want = UnityWebappsBackend.want(tempdir.path)
        self.assertEqual(0, want['score'])
        filename = self.getUniqueString() + ".user.js"
        tree[filename] = {}
        tempdir = self.useFixture(FileTree(tree))
        want = UnityWebappsBackend.want(tempdir.path)
        self.assertEqual(20, want['score'])

src/p/k/pkgme-0.4.3/pkgme/tests/test_write.py   pkgme(Download)
    def do_write(self, tempdir=None):
        if tempdir is None:
            tempdir = self.useFixture(TempDir())
        writer = self.get_writer()
        writer.write(tempdir.path)
        return tempdir
 
    def test_write_creates_target_dir(self):
        writer = self.get_writer()
        tempdir = self.useFixture(TempDir())
    def test_write_creates_needed_subdirs(self):
        writer = self.get_writer()
        tempdir = self.useFixture(TempDir())
        subdir = self.getUniqueString()
        package_file = SimplePackageFile(
    def test_write_accepts_existing_subdir(self):
        writer = self.get_writer()
        tempdir = self.useFixture(TempDir())
        subdir = self.getUniqueString()
        package_file = SimplePackageFile(
    def test_write_creates_file(self):
        writer = self.get_writer()
        tempdir = self.useFixture(TempDir())
        filename = self.getUniqueString()
        package_file = SimplePackageFile(filename)

  1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9  Next