Skip to main content

Phone number generator for libphonenumber

Project description

Phone Gen

Build Status codecov PyPI PyPI - Python Version PyPI - Implementation

Phone number generator for Google's libphonenumber library

This module was created exclusively for generating test data, when it is necessary to enter phone numbers in fields that are validated by the libphonenumber library or its ports.

Installation

Install using pip with

pip install phone-gen

Example

from phone_gen import PhoneNumber

phone_number = PhoneNumber('GB')

# Get a phone number
number = phone_number.get_number()
print(number)  # +442908124840

# Get a country code
country_code = phone_number.get_code()
print(country_code)  # 44

# Get a phone number without a country code
number = phone_number.get_number(full=False)
print(number)  # 183782623
pytest fixture
import pytest
from phone_gen import PhoneNumber


@pytest.fixture
def phone_number():
    def wrap(code):
        return PhoneNumber(code).get_number()

    yield wrap


def test_one(phone_number):
    number = phone_number('DE')
    ...

Resources

Contributing

Contributions are very welcome.

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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

phone_gen-1.0.0-py2.py3-none-any.whl (19.8 kB view hashes)

Uploaded Python 2 Python 3

Supported by

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