<s> try : <EOL> from StringIO import StringIO <EOL> except ImportError : <EOL> from io import StringIO <EOL> import pynmea2 <EOL> TEST_DATA = """<STR_LIT>""" <EOL> def test_file ( ) : <EOL> nmeafile = pynmea2 . NMEAFile ( StringIO ( TEST_DATA ) ) <EOL> nmea_strings = nmeafile . read ( ) <EOL> assert len ( nmea_strings ) == <NUM_LIT:10> <EOL> assert all ( [ isinstance ( s , pynmea2 . NMEASentence ) for s in nmea_strings ] ) <EOL> del nmeafile <EOL> with pynmea2 . NMEAFile ( StringIO ( TEST_DATA ) ) as _f : <EOL> nmea_strings = [ _f . readline ( ) for i in range ( <NUM_LIT:10> ) ] <EOL> assert len ( nmea_strings ) == <NUM_LIT:10> <EOL> assert all ( [ isinstance ( s , pynmea2 . NMEASentence ) for s in nmea_strings ] ) <EOL> with pynmea2 . NMEAFile ( StringIO ( TEST_DATA ) ) as _f : <EOL> nmea_strings = [ s for s in _f ] <EOL> assert len ( nmea_strings ) == <NUM_LIT:10> <EOL> assert all ( [ isinstance ( s , pynmea2 . NMEASentence ) for s in nmea_strings ] ) <EOL> with pynmea2 . NMEAFile ( StringIO ( TEST_DATA ) ) as _f : <EOL> nmea_strings = [ _f . next ( ) for i in range ( <NUM_LIT:10> ) ] <EOL> assert len ( nmea_strings ) == <NUM_LIT:10> <EOL> assert all ( [ isinstance ( s , pynmea2 . NMEASentence ) for s in nmea_strings ] ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> test_file ( ) </s>
