Пример #1
0
    def _created_test(self, get_config, servers_yaml, rootcap):
        original_tempdir = tempfile.tempdir

        tempdir = self.useFixture(TempDir())
        nodedir = tempdir.join(b"node")
        privatedir = tempdir.join(b"node", b"private")
        makedirs(privatedir)
        config = get_config(nodedir, b"tub.port")

        # Provide it a statically configured server to connect to.
        config.write_private_config(
            b"servers.yaml",
            servers_yaml,
        )
        if rootcap:
            config.write_private_config(
                b"rootcap",
                b"dddddddd",
            )

        try:
            d = create_client_from_config(config)
            self.assertThat(
                d,
                succeeded(
                    AfterPreprocessing(
                        lambda client: client.getServiceNamed(SERVICE_NAME),
                        Always(),
                    ),
                ),
            )
        finally:
            # create_client_from_config (indirectly) rewrites tempfile.tempdir
            # in a destructive manner that fails most of the rest of the test
            # suite if we don't clean it up.  We can't do this with a tearDown
            # or a fixture or an addCleanup because hypothesis doesn't run any
            # of those at the right time. :/
           tempfile.tempdir = original_tempdir
Пример #2
0
 def create_node(self):
     return create_client_from_config(
         self.config,
         _introducer_factory=MemoryIntroducerClient,
     )