Ejemplo n.º 1
0
    def testReadFile(self):
        # write an arbitrary file to disk
        filepath = 'TestFunctions.txt'
        expected = """
this is some sample text from a file
"""

        with open(filepath, 'w') as f:
            f.write(expected)

        # read from file
        with util.open(filepath) as f:
            self.assertEqual(expected, f.read())
Ejemplo n.º 2
0
    def testUrlOpen(self):
        # write an arbitrary file to disk
        filepath = os.path.abspath('TestFunctions.txt')
        expected = """
this is some sample text from a url
"""
        # write this to disk
        with open(filepath, 'w') as f:
            f.write(expected)

        # read from url
        with util.open('file://%s' % filepath) as f:
            self.assertEqual(expected, f.read())