Example #1
0
    def test_sync(self):
        assert normalize_backend(Backend("sync"),
                                 async_mode=False) == Backend("sync")
        assert normalize_backend("sync", async_mode=False) == Backend("sync")
        assert normalize_backend(None, async_mode=False) == Backend("sync")

        with pytest.raises(ValueError) as excinfo:
            normalize_backend(Backend("trio"), async_mode=False)
        assert "trio backend needs to be run in async mode" == str(
            excinfo.value)
Example #2
0
    def test_async(self):
        assert normalize_backend(Backend("trio"),
                                 async_mode=True) == Backend("trio")
        assert normalize_backend("twisted",
                                 async_mode=True) == Backend("twisted")

        with pytest.raises(ValueError) as excinfo:
            normalize_backend(Backend("sync"), async_mode=True)
        assert ('sync backend needs to be run in sync mode' == str(
            excinfo.value))

        from twisted.internet import reactor
        assert (normalize_backend(Backend("twisted", reactor=reactor),
                                  async_mode=True) == Backend("twisted",
                                                              reactor=reactor))
Example #3
0
 def test_sync(self):
     load_backend(normalize_backend("sync", async_mode=False))
Example #4
0
    def test_unknown(self):
        with pytest.raises(ValueError) as excinfo:
            normalize_backend("_unknown", async_mode=False)

        assert "unknown backend specifier _unknown" == str(excinfo.value)