Пример #1
0
    def test_initialize_local_options(self, options: Options):
        options.password = "******"
        options.timeout = 1337
        d = Downloader(options)

        assert d._options is not options
        assert str(d._options) == str(options)
        assert str(d._options) != str(opt)

        options.password = "******"
        assert d._options.password == "foo"
Пример #2
0
    def test_write_config(self, options: Options, config_backup):
        options.timeout = 1337
        options.license = License.COMMERCIAL
        options.password = "******"
        options.write()

        new_opt = Options.from_config()
        for k, v in options.__dict__.items():
            if k == "cache":
                assert type(new_opt.cache) == type(options.cache)  # noqa: E721
            elif k == "password":
                # don't store the password in the file
                assert getattr(new_opt, k) is None
            elif k not in ("timeout", "license"):
                assert getattr(new_opt, k) == v

        assert new_opt.timeout == 1337
        assert new_opt.license == License.COMMERCIAL
Пример #3
0
    def test_password(self, options: Options, pwd: Optional[str]):
        options.password = pwd

        assert options.password == pwd
Пример #4
0
 def test_invalid_password_type(self, options: Options):
     with pytest.raises(TypeError):
         options.password = 42