Skip to main content

Generate fake files.

Project description

Generate fake files

PyPI Version Supported Python versions Build Status Documentation Status MIT Coverage

Prerequisites

  • Core package requires Python 3.7, 3.8, 3.9, 3.10 and 3.11.

  • Django integration (with factory_boy) has been tested with Django 2.2, 3.0, 3.1, 3.2, 4.0 and 4.1.

Documentation

Documentation is available on Read the Docs.

Installation

Latest stable version on PyPI:

pip install faker-file[all]

Or development version from GitHub:

pip install https://github.com/barseghyanartur/faker-file/archive/main.tar.gz

Supported file types

  • DOCX

  • PDF

  • PPTX

  • TXT

  • ZIP

Usage examples

Standalone

from faker_file.providers.txt_file import TxtFileProvider

file = TxtFileProvider(None).txt_file()

With Faker

from faker import Faker
from faker_file.providers.txt_file import TxtFileProvider

FAKER = Faker()
FAKER.add_provider(TxtFileProvider)

file = FAKER.txt_file()

With factory_boy

upload/models.py

from django.db import models

class Upload(models.Model):

    # ...
    upload = models.FileField()

upload/factory.py

Note, that when using faker-file with Django, you need to pass your MEDIA_ROOT setting as root_path value (which is by default set to tempfile.gettempdir()).

import factory
from django.conf import settings
from factory import Faker
from factory.django import DjangoModelFactory
from faker_file.providers.docx_file import DocxFileProvider

from upload.models import Upload

factory.Faker.add_provider(DocxFileProvider)

class UploadFactory(DjangoModelFactory):

    # ...
    file = Faker("docx_file", root_path=settings.MEDIA_ROOT)

    class Meta:
        model = Upload

Testing

Simply type:

pytest -vvv

Or use tox:

tox

Or use tox to check specific env:

tox -e py310-django41

Writing documentation

Keep the following hierarchy.

=====
title
=====

header
======

sub-header
----------

sub-sub-header
~~~~~~~~~~~~~~

sub-sub-sub-header
^^^^^^^^^^^^^^^^^^

sub-sub-sub-sub-header
++++++++++++++++++++++

sub-sub-sub-sub-sub-header
**************************

License

MIT

Support

For any security issues contact me at the e-mail given in the Author section.

For overall issues, go to GitHub.

Author

Artur Barseghyan <artur.barseghyan@gmail.com>

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

faker-file-0.1.tar.gz (52.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

faker_file-0.1-py2.py3-none-any.whl (14.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file faker-file-0.1.tar.gz.

File metadata

  • Download URL: faker-file-0.1.tar.gz
  • Upload date:
  • Size: 52.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for faker-file-0.1.tar.gz
Algorithm Hash digest
SHA256 02feb46f4895a6360b4a75b78d01e6f9c25386db6792af0bf726c8a652ae4b0a
MD5 153d4cf0a3050d0b14a26f903f4b4cab
BLAKE2b-256 8442011778de4a4573dd5f0c98b484848943a0562c0b196d9f2b4fa48ff778b2

See more details on using hashes here.

File details

Details for the file faker_file-0.1-py2.py3-none-any.whl.

File metadata

  • Download URL: faker_file-0.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 14.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for faker_file-0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 385a938a067b44aac655d36e680ae5530d6e02ec636c37b58f6622b7e01a5276
MD5 650290a967a440a2949f54602c479d52
BLAKE2b-256 6f9e70de6fb2c7fddb41927ff1eadf511867e052adf1d6f72ab1d691043912e1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page