<commit_before>import pytest

from .factories import BookFactory, BookSpecimenFactory

pytestmark = pytest.mark.django_db


def test_it_should_create_a_default_book_from_factory():
    book = BookFactory()
    assert book.pk is not None
    assert unicode(book)


def test_it_should_override_book_fields_passed_to_factory():
    book = BookFactory()
    assert book.title.startswith('Test book')
    another = BookFactory(title="My custom title")
    assert another.title == "My custom title"


def test_it_should_create_a_default_book_specimen_from_factory():
    specimen = BookSpecimenFactory()
    assert specimen.pk is not None
    assert unicode(specimen)


def test_it_should_override_specimen_fields_passed_to_factory():
    book = BookFactory()
    specimen = BookSpecimenFactory(book=book)
    assert specimen.book == book<commit_msg>Test that BookSpecimenFactory also creates the related book<commit_after>import pytest

from .factories import BookFactory, BookSpecimenFactory

pytestmark = pytest.mark.django_db


def test_it_should_create_a_default_book_from_factory():
    book = BookFactory()
    assert book.pk is not None
    assert unicode(book)


def test_it_should_override_book_fields_passed_to_factory():
    book = BookFactory()
    assert book.title.startswith('Test book')
    another = BookFactory(title="My custom title")
    assert another.title == "My custom title"


def test_it_should_create_a_default_book_specimen_from_factory():
    specimen = BookSpecimenFactory()
    assert specimen.pk is not None
    assert specimen.book.pk is not None
    assert unicode(specimen)


def test_it_should_override_specimen_fields_passed_to_factory():
    book = BookFactory()
    specimen = BookSpecimenFactory(book=book)
    assert specimen.book == book
{'fraction_non_alphanumeric': 0.07102593010146561, 'fraction_numerical': 0.0, 'mean_word_length': 5.141868512110727, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3689999', 'n_tokens_mistral': 547, 'n_tokens_neox': 531, 'n_words': 123}