コード例 #1
0
ファイル: test_util.py プロジェクト: tempcyc/mrjob
    def test_read_large_bz2_file(self):
        # catch incorrect use of bz2 library (Issue #814)

        input_bz2_path = os.path.join(self.tmp_dir, "input.bz2")
        input_bz2 = bz2.BZ2File(input_bz2_path, "wb")

        # can't just repeat same value, because we need the file to be
        # compressed! 50000 lines is too few to catch the bug.
        with random_seed(0):
            for _ in range(100000):
                input_bz2.write((random_identifier() + "\n").encode("ascii"))
            input_bz2.close()

        # now expect to read back the same bytes
        with random_seed(0):
            num_lines = 0
            for line in read_file(input_bz2_path):
                self.assertEqual(line, (random_identifier() + "\n").encode("ascii"))
                num_lines += 1

            self.assertEqual(num_lines, 100000)
コード例 #2
0
ファイル: test_util.py プロジェクト: mikekap/mrjob
    def test_read_large_bz2_file(self):
        # catch incorrect use of bz2 library (Issue #814)

        input_bz2_path = os.path.join(self.tmp_dir, 'input.bz2')
        input_bz2 = bz2.BZ2File(input_bz2_path, 'wb')

        # can't just repeat same value, because we need the file to be
        # compressed! 50000 lines is too few to catch the bug.
        with random_seed(0):
            for _ in range(100000):
                input_bz2.write((random_identifier() + '\n').encode('ascii'))
            input_bz2.close()

        # now expect to read back the same bytes
        with random_seed(0):
            num_lines = 0
            for line in read_file(input_bz2_path):
                self.assertEqual(line,
                                 (random_identifier() + '\n').encode('ascii'))
                num_lines += 1

            self.assertEqual(num_lines, 100000)
コード例 #3
0
ファイル: test_util.py プロジェクト: mikekap/mrjob
 def test_no_collisions_possible_ever(self):
     # heh
     with random_seed(0):
         self.assertNotEqual(random_identifier(), random_identifier())
コード例 #4
0
ファイル: test_util.py プロジェクト: mikekap/mrjob
 def test_format(self):
     with random_seed(0):
         random_id = random_identifier()
     self.assertEqual(len(random_id), 16)
     self.assertFalse(set(random_id) - set('0123456789abcdef'))
コード例 #5
0
ファイル: test_util.py プロジェクト: anirudhreddy92/mrjob
 def test_no_collisions_possible_ever(self):
     # heh
     with random_seed(0):
         self.assertNotEqual(random_identifier(), random_identifier())
コード例 #6
0
ファイル: test_util.py プロジェクト: anirudhreddy92/mrjob
 def test_format(self):
     with random_seed(0):
         random_id = random_identifier()
     self.assertEqual(len(random_id), 16)
     self.assertFalse(set(random_id) - set('0123456789abcdef'))