aboutsummaryrefslogtreecommitdiff
path: root/pyfakefs/pytest_tests/pytest_plugin_test.py
diff options
context:
space:
mode:
Diffstat (limited to 'pyfakefs/pytest_tests/pytest_plugin_test.py')
-rw-r--r--pyfakefs/pytest_tests/pytest_plugin_test.py42
1 files changed, 34 insertions, 8 deletions
diff --git a/pyfakefs/pytest_tests/pytest_plugin_test.py b/pyfakefs/pytest_tests/pytest_plugin_test.py
index 5632ff6..51f95cb 100644
--- a/pyfakefs/pytest_tests/pytest_plugin_test.py
+++ b/pyfakefs/pytest_tests/pytest_plugin_test.py
@@ -2,24 +2,26 @@
import os
import tempfile
+from pyfakefs.fake_filesystem import OSType
from pyfakefs.fake_filesystem_unittest import Pause
+import pyfakefs.pytest_tests.io
def test_fs_fixture(fs):
- fs.create_file('/var/data/xx1.txt')
- assert os.path.exists('/var/data/xx1.txt')
+ fs.create_file("/var/data/xx1.txt")
+ assert os.path.exists("/var/data/xx1.txt")
def test_fs_fixture_alias(fake_filesystem):
- fake_filesystem.create_file('/var/data/xx1.txt')
- assert os.path.exists('/var/data/xx1.txt')
+ fake_filesystem.create_file("/var/data/xx1.txt")
+ assert os.path.exists("/var/data/xx1.txt")
def test_both_fixtures(fs, fake_filesystem):
- fake_filesystem.create_file('/var/data/xx1.txt')
- fs.create_file('/var/data/xx2.txt')
- assert os.path.exists('/var/data/xx1.txt')
- assert os.path.exists('/var/data/xx2.txt')
+ fake_filesystem.create_file("/var/data/xx1.txt")
+ fs.create_file("/var/data/xx2.txt")
+ assert os.path.exists("/var/data/xx1.txt")
+ assert os.path.exists("/var/data/xx2.txt")
assert fs == fake_filesystem
@@ -50,3 +52,27 @@ def test_pause_resume_contextmanager(fs):
assert os.path.exists(real_temp_file.name)
assert not os.path.exists(real_temp_file.name)
assert os.path.exists(fake_temp_file.name)
+
+
+def test_use_own_io_module(fs):
+ filepath = "foo.txt"
+ with open(filepath, "w") as f:
+ f.write("bar")
+
+ stream = pyfakefs.pytest_tests.io.InputStream(filepath)
+ assert stream.read() == "bar"
+
+
+def test_switch_to_windows(fs):
+ fs.os = OSType.WINDOWS
+ assert os.path.exists(tempfile.gettempdir())
+
+
+def test_switch_to_linux(fs):
+ fs.os = OSType.LINUX
+ assert os.path.exists(tempfile.gettempdir())
+
+
+def test_switch_to_macos(fs):
+ fs.os = OSType.MACOS
+ assert os.path.exists(tempfile.gettempdir())