How to use shiv - 10 common examples

To help you get started, we’ve selected a few shiv 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 linkedin / shiv / test / test_bootstrap.py View on Github external
def test_import_string(self):
        assert import_string("site.addsitedir") == addsitedir
        assert import_string("site:addsitedir") == addsitedir
        assert import_string("code.interact") == interact
        assert import_string("code:interact") == interact

        # test things not already imported
        func = import_string("os.path:join")
        from os.path import join

        assert func == join

        # test something already imported
        import shiv

        assert import_string("shiv") == shiv == sys.modules["shiv"]

        # test bogus imports raise properly
        with pytest.raises(ImportError):
            import_string("this is bogus!")
github linkedin / shiv / test / test_bootstrap.py View on Github external
def test_import_string(self):
        assert import_string("site.addsitedir") == addsitedir
        assert import_string("site:addsitedir") == addsitedir
        assert import_string("code.interact") == interact
        assert import_string("code:interact") == interact

        # test things not already imported
        func = import_string("os.path:join")
        from os.path import join

        assert func == join

        # test something already imported
        import shiv

        assert import_string("shiv") == shiv == sys.modules["shiv"]

        # test bogus imports raise properly
        with pytest.raises(ImportError):
github linkedin / shiv / test / test_bootstrap.py View on Github external
assert import_string("code:interact") == interact

        # test things not already imported
        func = import_string("os.path:join")
        from os.path import join

        assert func == join

        # test something already imported
        import shiv

        assert import_string("shiv") == shiv == sys.modules["shiv"]

        # test bogus imports raise properly
        with pytest.raises(ImportError):
            import_string("this is bogus!")
github linkedin / shiv / test / test_bootstrap.py View on Github external
def test_import_string(self):
        assert import_string("site.addsitedir") == addsitedir
        assert import_string("site:addsitedir") == addsitedir
        assert import_string("code.interact") == interact
        assert import_string("code:interact") == interact

        # test things not already imported
        func = import_string("os.path:join")
        from os.path import join

        assert func == join

        # test something already imported
        import shiv

        assert import_string("shiv") == shiv == sys.modules["shiv"]

        # test bogus imports raise properly
        with pytest.raises(ImportError):
            import_string("this is bogus!")
github linkedin / shiv / test / test_bootstrap.py View on Github external
def test_import_string(self):
        assert import_string("site.addsitedir") == addsitedir
        assert import_string("site:addsitedir") == addsitedir
        assert import_string("code.interact") == interact
        assert import_string("code:interact") == interact

        # test things not already imported
        func = import_string("os.path:join")
        from os.path import join

        assert func == join

        # test something already imported
        import shiv

        assert import_string("shiv") == shiv == sys.modules["shiv"]

        # test bogus imports raise properly
        with pytest.raises(ImportError):
            import_string("this is bogus!")
github linkedin / shiv / test / test_bootstrap.py View on Github external
def test_import_string(self):
        assert import_string("site.addsitedir") == addsitedir
        assert import_string("site:addsitedir") == addsitedir
        assert import_string("code.interact") == interact
        assert import_string("code:interact") == interact

        # test things not already imported
        func = import_string("os.path:join")
        from os.path import join

        assert func == join

        # test something already imported
        import shiv

        assert import_string("shiv") == shiv == sys.modules["shiv"]

        # test bogus imports raise properly
        with pytest.raises(ImportError):
            import_string("this is bogus!")
github linkedin / shiv / test / test_bootstrap.py View on Github external
def test_import_string(self):
        assert import_string("site.addsitedir") == addsitedir
        assert import_string("site:addsitedir") == addsitedir
        assert import_string("code.interact") == interact
        assert import_string("code:interact") == interact

        # test things not already imported
        func = import_string("os.path:join")
        from os.path import join

        assert func == join

        # test something already imported
        import shiv

        assert import_string("shiv") == shiv == sys.modules["shiv"]

        # test bogus imports raise properly
github linkedin / shiv / test / test_bootstrap.py View on Github external
def test_overrides(self):
        now = str(datetime.now())
        version = "0.0.1"
        env = Environment(now, version)

        assert env.built_at == now
        assert env.shiv_version == version

        assert env.entry_point is None
        with env_var("SHIV_ENTRY_POINT", "test"):
            assert env.entry_point == "test"

        assert env.interpreter is None
        with env_var("SHIV_INTERPRETER", "1"):
            assert env.interpreter is not None

        assert env.root is None
        with env_var("SHIV_ROOT", "tmp"):
            assert env.root == Path("tmp")
github linkedin / shiv / test / test_bootstrap.py View on Github external
def test_roundtrip(self):
        now = str(datetime.now())
        version = "0.0.1"
        env = Environment(now, version)
        env_as_json = env.to_json()
        env_from_json = Environment.from_json(env_as_json)
        assert env.__dict__ == env_from_json.__dict__
github linkedin / shiv / test / test_builder.py View on Github external
def test_archive_permissions(self, sp, env):
        with tempfile.TemporaryDirectory() as tmpdir:
            target = Path(tmpdir, "test.zip")
            create_archive(sp, target, sys.executable, "code:interact", env)

            assert target.stat().st_mode & UGOX == UGOX