コード例 #1
0
 def test1_special_mkdir(self):
     'QueueBase._special_mkdir()'
     assert QueueBase._special_mkdir(self.qdir) is True
     assert QueueBase._special_mkdir(self.qdir) is False
     # test against a file
     test_file = os.path.join(self.qdir, 'foo')
     open(test_file, 'w').write('bar')
     self.failUnlessRaises(OSError, QueueBase._special_mkdir, (test_file))
コード例 #2
0
 def test1_special_mkdir(self):
     'QueueBase._special_mkdir()'
     assert QueueBase._special_mkdir(self.qdir) is True
     assert QueueBase._special_mkdir(self.qdir) is False
     # test against a file
     test_file = os.path.join(self.qdir, 'foo')
     open(test_file, 'w').write('bar')
     self.failUnlessRaises(OSError, QueueBase._special_mkdir, (test_file))
コード例 #3
0
 def test4_file_write(self):
     'QueueBase._file_write()'
     QueueBase._file_write(self.tempfile, 0, False, 'a\n'.encode())
     os.unlink(self.tempfile)
     QueueBase._file_write(self.tempfile, 0, False,
                           ('a' * (2**10) * 10).encode())
     os.unlink(self.tempfile)
     for t in [1, [], (), {}, object]:
         self.failUnlessRaises(TypeError, QueueBase._file_write, ('', t))
コード例 #4
0
 def test4_file_write(self):
     'QueueBase._file_write()'
     QueueBase._file_write(self.tempfile, 0, False, 'a\n'.encode())
     os.unlink(self.tempfile)
     QueueBase._file_write(self.tempfile, 0,
                           False, ('a' * (2 ** 10) * 10).encode())
     os.unlink(self.tempfile)
     for t in [1, [], (), {}, object]:
         self.failUnlessRaises(TypeError, QueueBase._file_write, ('', t))
コード例 #5
0
 def test5_file_read(self):
     'QueueBase._file_read()'
     text = 'hello\n'.encode()
     open(self.tempfile, 'wb').write(text)
     text_in = QueueBase._file_read(self.tempfile, False)
     self.assertEqual(text, text_in)
     # utf8
     try:
         text = 'Élément \u263A\n'.decode("utf-8")
     except AttributeError:
         text = 'Élément \u263A\n'
     codecs.open(self.tempfile, 'w', 'utf8').write(text)
     text_in = QueueBase._file_read(self.tempfile, True)
     self.assertEqual(text, text_in)
コード例 #6
0
 def test5_file_read(self):
     'QueueBase._file_read()'
     text = 'hello\n'.encode()
     open(self.tempfile, 'wb').write(text)
     text_in = QueueBase._file_read(self.tempfile, False)
     self.assertEqual(text, text_in)
     # utf8
     try:
         text = 'Élément \u263A\n'.decode("utf-8")
     except AttributeError:
         text = 'Élément \u263A\n'
     codecs.open(self.tempfile, 'w', 'utf8').write(text)
     text_in = QueueBase._file_read(self.tempfile, True)
     self.assertEqual(text, text_in)
コード例 #7
0
    def test3_file_create(self):
        'QueueBase._file_create()'
        # File in non existent directory should produce ENOENT.
        fn = os.getcwd() + "/nodir/nofile"
        try:
            QueueBase._file_create(fn, 0, False)
        except OSError:
            error = sys.exc_info()[1]
            assert error.errno == errno.ENOENT

        QueueBase._file_create(self.tempfile, 0, False)
        self.failUnlessRaises(OSError, QueueBase._file_create,
                              *(self.tempfile, 0, False))
        os.unlink(self.tempfile)
        # utf8 data
        QueueBase._file_create(self.tempfile, 0, True)
        self.failUnlessRaises(OSError, QueueBase._file_create,
                              *(self.tempfile, 0, True))
コード例 #8
0
    def test3_file_create(self):
        'QueueBase._file_create()'
        # File in non existent directory should produce ENOENT.
        fn = os.getcwd() + "/nodir/nofile"
        try:
            QueueBase._file_create(fn, 0, False)
        except OSError:
            error = sys.exc_info()[1]
            assert error.errno == errno.ENOENT

        QueueBase._file_create(self.tempfile, 0, False)
        self.failUnlessRaises(OSError,
                              QueueBase._file_create,
                              *(self.tempfile, 0, False))
        os.unlink(self.tempfile)
        # utf8 data
        QueueBase._file_create(self.tempfile, 0, True)
        self.failUnlessRaises(OSError,
                              QueueBase._file_create,
                              *(self.tempfile, 0, True))
コード例 #9
0
 def test2_name(self):
     'QueueBase._name()'
     n = QueueBase._name(7)
     assert len(n) == 14
     assert n.endswith('%01x' % 7)
コード例 #10
0
 def test2_name(self):
     'QueueBase._name()'
     n = QueueBase._name(7)
     assert len(n) == 14
     assert n.endswith('%01x' % 7)