Ejemplo n.º 1
0
def custom_zw():
    zw = common.ZipWriter(
        zip_filename=common.random_string(4, 6),
        processed_size_callback=lambda _: 'custom_callback'
    )
    yield zw
    zw.close()
    os.remove(zw.zip_filename)
Ejemplo n.º 2
0
def custom_zw():
    zw = common.ZipWriter(
        zip_filename=common.random_string(4, 6),
        processed_size_callback=lambda _: 'custom_callback'
    )
    yield zw
    zw.close()
    os.remove(zw.zip_filename)
class TestZipWriterCustom:
    @pytest.mark.parametrize('test_input', (common.random_string(
        random.randint(2, 50), random.choice((None, random.randint(2, 50))))
                                            for _ in range(50)))
    def test_random_string_regex(self, test_input):
        assert bool(RANDOM_STR_REGEX.match(test_input))

    def test_custom_filename(self, custom_zw):
        assert bool(RANDOM_STR_REGEX.match(custom_zw.zip_filename))

    def test_custom_callback(self, custom_zw):
        assert custom_zw.processed_size_callback(None) == 'custom_callback'