"""
.. codeauthor:: Tsuyoshi Hombashi <tsuyoshi.hombashi@gmail.com>
"""


import platform
import re

import pytest
from typepy import is_not_null_string

import subprocrunner
from subprocrunner import Which


class Test_Which_constructor:
    @pytest.mark.parametrize(
        ["value", "expected"],
        [
            [0, subprocrunner.CommandError],
            ["", subprocrunner.CommandError],
            [None, subprocrunner.CommandError],
        ],
    )
    def test_exception(self, value, expected):
        with pytest.raises(expected):
            Which(value)


class Test_Which_repr:
    @pytest.mark.skipif(platform.system() == "Windows", reason="platform dependent tests")
    @pytest.mark.parametrize(
        ["value", "expected_regexp"],
        [
            ["ls", re.compile("^command=ls, is_exist=True, abspath=.*?bin/ls$")],
            [
                "__not_exist_command__",
                re.compile("^command=__not_exist_command__, is_exist=False$"),
            ],
        ],
    )
    def test_normal(self, value, expected_regexp):
        assert expected_regexp.search(str(Which(value))) is not None


class Test_Which_is_exist:
    @pytest.mark.skipif(platform.system() == "Windows", reason="platform dependent tests")
    @pytest.mark.parametrize(
        ["value", "expected"], [["ls", True], ["/bin/ls", True], ["__not_exist_command__", False]]
    )
    def test_normal_linux(self, value, expected):
        assert Which(value).is_exist() == expected

    @pytest.mark.skipif("platform.system() != 'Windows'")
    @pytest.mark.parametrize(
        ["value", "expected"], [["ping", True], ["__not_exist_command__", False]]
    )
    def test_normal_windows(self, value, expected):
        which = Which(value)
        assert which.is_exist() == expected


class Test_Which_verify:
    @pytest.mark.skipif(platform.system() == "Windows", reason="platform dependent tests")
    @pytest.mark.parametrize(["value"], [["ls"]])
    def test_normal_linux(self, value):
        Which(value).verify()

    @pytest.mark.skipif("platform.system() != 'Windows'")
    @pytest.mark.parametrize(["value"], [["ping"]])
    def test_normal_windows(self, value):
        Which(value).verify()

    @pytest.mark.parametrize(
        ["value", "expected"], [["__not_exist_command__", subprocrunner.CommandError]]
    )
    def test_exception(self, value, expected):
        with pytest.raises(expected):
            Which(value).verify()


class Test_Which_abspath:
    @pytest.mark.skipif(platform.system() == "Windows", reason="platform dependent tests")
    @pytest.mark.parametrize(["value"], [["ls"]])
    def test_normal_linux(self, value):
        assert is_not_null_string(Which(value).abspath())

    @pytest.mark.skipif("platform.system() != 'Windows'")
    @pytest.mark.parametrize(["value"], [["ping"]])
    def test_normal_windows(self, value):
        assert is_not_null_string(Which(value).abspath())

    @pytest.mark.parametrize(["value"], [["__not_exist_command__"]])
    def test_abnormal(self, value):
        assert Which(value).abspath() is None

@@ -1504,33 +1504,32 @@
 est.mark.skipif(
-%22
 platform.system(
@@ -1529,33 +1529,67 @@
 system() != 
-'
+%22
 Windows
-'
+%22, reason=%22platform dependent tests
 %22)%0A    @pyte
@@ -2077,33 +2077,32 @@
 est.mark.skipif(
-%22
 platform.system(
@@ -2102,33 +2102,67 @@
 system() != 
-'
+%22
 Windows
-'
+%22, reason=%22platform dependent tests
 %22)%0A    @pyte
@@ -2811,17 +2811,16 @@
 .skipif(
-%22
 platform
@@ -2836,17 +2836,51 @@
  != 
-'
+%22
 Windows
-'
+%22, reason=%22platform dependent tests
 %22)%0A 

Modify pytest.mark.skipif statements