def test_basic(self):
        filename = os.path.join(tempfile.gettempdir(), 'file.txt')

        target = FileTarget(filename)

        target.multipart_filename = 'file001.txt'

        target.start()
        self.assertEqual(target.filename, filename)
        self.assertEqual(target.multipart_filename, 'file001.txt')
        self.assertTrue(os.path.exists(filename))

        target.data_received(b'hello')
        target.data_received(b' ')
        target.data_received(b'world')

        target.finish()

        self.assertTrue(os.path.exists(filename))

        self.assertEqual(target.filename, filename)
        self.assertEqual(target.multipart_filename, 'file001.txt')

        with open(filename, 'rb') as file_:
            self.assertEqual(file_.read(), b'hello world')
def test_file_target_basic():
    filename = os.path.join(tempfile.gettempdir(), 'file.txt')

    target = FileTarget(filename)

    target.multipart_filename = 'file001.txt'

    target.start()

    assert target.filename == filename
    assert target.multipart_filename == 'file001.txt'
    assert os.path.exists(filename)

    target.data_received(b'hello')
    target.data_received(b' ')
    target.data_received(b'world')

    target.finish()

    assert target.filename == filename
    assert target.multipart_filename == 'file001.txt'
    assert os.path.exists(filename)

    with open(filename, 'rb') as file_:
        assert file_.read() == b'hello world'