コード例 #1
0
    def test_the_default_config_paths_are_subdirectories_of_the_caller(self):
        region = Region("area", Config())
        this_dir = Path(__file__).parent

        assert_that(region._config.image_dir, is_(str(this_dir / "images")))
        assert_that(region._config.screenshot_dir,
                    is_(str(this_dir / "screenshots")))
コード例 #2
0
ファイル: test_config.py プロジェクト: sneakypete81/clickshot
    def test_config_can_be_loaded_from_dict(self):
        config_dict = {
            "image_dir": "/img/",
            "screenshot_dir": "/scr/",
            "timeout_seconds": 10,
        }

        config = Config(**config_dict)

        assert_that(config.image_dir, is_("/img/"))
        assert_that(config.screenshot_dir, is_("/scr/"))
        assert_that(config.timeout_seconds, is_(10))
コード例 #3
0
    def test_system_image_dir_is_used(self, mocker, tmp_path):
        (tmp_path / "images" / "Darwin").mkdir(parents=True)
        mocker.patch(
            "clickshot.region.platform.system").return_value = "Darwin"
        mocker.patch(
            "clickshot.region.inspect.stack").return_value = mock_stack(
                mocker, tmp_path)

        region = Region("area", Config())

        assert_that(region._config.image_dir,
                    is_(str(tmp_path / "images" / "Darwin")))
コード例 #4
0
    def test_mac_ver_image_dir_is_preferred(self, mocker, tmp_path):
        (tmp_path / "images" / "Darwin").mkdir(parents=True)
        (tmp_path / "images" / "Darwin-19.4.0").mkdir(parents=True)
        (tmp_path / "images" / "Darwin-10.15.4").mkdir(parents=True)
        mocker.patch(
            "clickshot.region.platform.system").return_value = "Darwin"
        mocker.patch(
            "clickshot.region.platform.release").return_value = "19.4.0"
        mocker.patch("clickshot.region.platform.mac_ver").return_value = (
            "10.15.4", )
        mocker.patch(
            "clickshot.region.inspect.stack").return_value = mock_stack(
                mocker, tmp_path)

        region = Region("area", Config())

        assert_that(region._config.image_dir,
                    is_(str(tmp_path / "images" / "Darwin-10.15.4")))
コード例 #5
0
ファイル: test_config.py プロジェクト: sneakypete81/clickshot
    def test_config_defaults_are_correct(self):
        config = Config(image_dir="/images/", screenshot_dir="/screenshots/")

        assert_that(config.image_dir, is_("/images/"))
        assert_that(config.screenshot_dir, is_("/screenshots/"))
        assert_that(config.timeout_seconds, is_(30))
コード例 #6
0
from clickshot import Config

config = Config()
コード例 #7
0
def default_config():
    return Config("img", "scr")