Created
March 25, 2021 10:09
-
-
Save Akasurde/0ff7bffd4d0934f1d4b699d7657d6126 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pytest | |
import re | |
from six import PY2 | |
def check_solaris_version(filename='/etc/release'): | |
with open(filename) as f: | |
content = f.readlines() | |
for line in content: | |
m = re.match(r'\s+Oracle Solaris (\d+\.\d+).*', line.rstrip()) | |
if m: | |
return True | |
return False | |
@pytest.fixture | |
def mocker_solaris(mocker): | |
# Read a mocked /etc/release file | |
mocked_etc_release_data = mocker.mock_open(read_data=" Oracle Solaris 12.0") | |
builtin_open = "__builtin__.open" if PY2 else "builtins.open" | |
mocker.patch(builtin_open, mocked_etc_release_data) | |
def test_check_solaris_version(mocker_solaris): | |
assert check_solaris_version(filename='fakefile') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment