<s> """<STR_LIT>""" <EOL> import os <EOL> import glob <EOL> import shutil <EOL> import tempfile <EOL> import sys <EOL> if sys . version_info < ( <NUM_LIT:2> , <NUM_LIT:7> ) : <EOL> import unittest2 as unittest <EOL> else : <EOL> import unittest <EOL> import pytest <EOL> from pyfakefs import fake_filesystem_unittest <EOL> class TestPyfakefsUnittest ( fake_filesystem_unittest . TestCase ) : <EOL> '''<STR_LIT>''' <EOL> def setUp ( self ) : <EOL> '''<STR_LIT>''' <EOL> self . setUpPyfakefs ( ) <EOL> def tearDown ( self ) : <EOL> '''<STR_LIT>''' <EOL> self . tearDownPyfakefs ( ) <EOL> @ unittest . skipIf ( sys . version_info > ( <NUM_LIT:2> , ) , "<STR_LIT>" ) <EOL> def test_file ( self ) : <EOL> '''<STR_LIT>''' <EOL> self . assertFalse ( os . path . exists ( '<STR_LIT>' ) ) <EOL> with file ( '<STR_LIT>' , '<STR_LIT:w>' ) as f : <EOL> f . write ( "<STR_LIT>" ) <EOL> self . assertTrue ( self . fs . Exists ( '<STR_LIT>' ) ) <EOL> with file ( '<STR_LIT>' ) as f : <EOL> content = f . read ( ) <EOL> self . assertEqual ( content , <EOL> '<STR_LIT>' ) <EOL> def test_open ( self ) : <EOL> '''<STR_LIT>''' <EOL> self . assertFalse ( os . path . exists ( '<STR_LIT>' ) ) <EOL> with open ( '<STR_LIT>' , '<STR_LIT:w>' ) as f : <EOL> f . write ( "<STR_LIT>" ) <EOL> self . assertTrue ( self . fs . Exists ( '<STR_LIT>' ) ) <EOL> with open ( '<STR_LIT>' ) as f : <EOL> content = f . read ( ) <EOL> self . assertEqual ( content , <EOL> '<STR_LIT>' ) <EOL> def test_os ( self ) : <EOL> '''<STR_LIT>''' <EOL> self . assertFalse ( self . fs . Exists ( '<STR_LIT>' ) ) <EOL> os . makedirs ( '<STR_LIT>' ) <EOL> self . assertTrue ( self . fs . Exists ( '<STR_LIT>' ) ) <EOL> def test_glob ( self ) : <EOL> '''<STR_LIT>''' <EOL> is_windows = sys . platform . startswith ( '<STR_LIT>' ) <EOL> self . assertEqual ( glob . glob ( '<STR_LIT>' ) , <EOL> [ ] ) <EOL> self . fs . CreateDirectory ( '<STR_LIT>' ) <EOL> matching_paths = glob . glob ( '<STR_LIT>' ) <EOL> if is_windows : <EOL> self . assertEqual ( matching_paths , [ r'<STR_LIT>' ] ) <EOL> else : <EOL> self . assertEqual ( matching_paths , [ '<STR_LIT>' ] ) <EOL> self . fs . CreateDirectory ( '<STR_LIT>' ) <EOL> matching_paths = glob . glob ( '<STR_LIT>' ) <EOL> if is_windows : <EOL> self . assertEqual ( matching_paths , [ r'<STR_LIT>' , r'<STR_LIT>' ] ) <EOL> else : <EOL> self . assertEqual ( matching_paths , [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> def test_shutil ( self ) : <EOL> '''<STR_LIT>''' <EOL> self . fs . CreateDirectory ( '<STR_LIT>' ) <EOL> self . fs . CreateDirectory ( '<STR_LIT>' ) <EOL> self . assertTrue ( self . fs . Exists ( '<STR_LIT>' ) ) <EOL> self . assertTrue ( self . fs . Exists ( '<STR_LIT>' ) ) <EOL> shutil . rmtree ( '<STR_LIT>' ) <EOL> self . assertFalse ( self . fs . Exists ( '<STR_LIT>' ) ) <EOL> def test_tempfile ( self ) : <EOL> '''<STR_LIT>''' <EOL> with tempfile . NamedTemporaryFile ( ) as tf : <EOL> tf . write ( b'<STR_LIT>' ) <EOL> name = tf . name <EOL> self . assertTrue ( self . fs . Exists ( tf . name ) ) <EOL> @ unittest . skipIf ( sys . version_info < ( <NUM_LIT:3> , <NUM_LIT:0> ) , "<STR_LIT>" ) <EOL> def test_tempdirectory ( self ) : <EOL> '''<STR_LIT>''' <EOL> with tempfile . TemporaryDirectory ( ) as td : <EOL> with open ( '<STR_LIT>' % td , '<STR_LIT:w>' ) as f : <EOL> self . assertTrue ( self . fs . Exists ( td ) ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
