Exemple #1
0
def test_find_in_files__binary_skip(find_in_files_setup):
    """Ensure files that we cannot decode are skipped over."""

    version_file = os.path.join(find_in_files_setup[1], "__version__.py")
    with open(version_file, "wb") as openversionfile:
        openversionfile.write(codecs.encode("__author__ = 'bob'\n", "utf-8"))
        openversionfile.write(codecs.encode("__version__ = '", "utf-8"))
        openversionfile.write(os.urandom(1024))
        openversionfile.write(codecs.encode("'\n", "utf-8"))

    find_in_files_asserts(guessing.find_in_files())
Exemple #2
0
def test_find_in_files__binary_skip(find_in_files_setup):
    """Ensure files that we cannot decode are skipped over."""

    version_file = os.path.join(find_in_files_setup[1], "__version__.py")
    with open(version_file, "wb") as openversionfile:
        openversionfile.write(codecs.encode("__author__ = 'bob'\n", "utf-8"))
        openversionfile.write(codecs.encode("__version__ = '", "utf-8"))
        openversionfile.write(os.urandom(1024))
        openversionfile.write(codecs.encode("'\n", "utf-8"))

    find_in_files_asserts(guessing.find_in_files())
Exemple #3
0
def test_find_in_files__ignored_dir(find_in_files_setup):
    """Ensure data is not considered from ignored directories."""

    ignored_dir = os.path.join(find_in_files_setup[0], "other-pkg.egg")
    os.mkdir(ignored_dir)
    with open(os.path.join(ignored_dir, "__init__.py"), "w") as openinit:
        openinit.write("\n".join([
            "__author__ = 'mohammad ali'",
            "__email__ = '*****@*****.**'",
            '__version__ = "2.0.0-beta"',
        ]))

    find_in_files_asserts(guessing.find_in_files())
Exemple #4
0
def test_find_in_files__file_too_large(find_in_files_setup):
    """Ensure files that are too large are ignored."""

    # if this file isn't ignored for size, it'll have a higher weight than
    # the data in __init__.py. it's also just over the limit for size
    version_file = os.path.join(find_in_files_setup[1], "__version__.py")

    with open(version_file, "w") as openversionfile:
        openversionfile.write("__author__ = 'bob'\n")
        for _ in range(100):
            openversionfile.write("{}\n".format(random_text(1024)))

    find_in_files_asserts(guessing.find_in_files())
Exemple #5
0
def test_find_in_files__file_too_large(find_in_files_setup):
    """Ensure files that are too large are ignored."""

    # if this file isn't ignored for size, it'll have a higher weight than
    # the data in __init__.py. it's also just over the limit for size
    version_file = os.path.join(find_in_files_setup[1], "__version__.py")

    with open(version_file, "w") as openversionfile:
        openversionfile.write("__author__ = 'bob'\n")
        for _ in range(100):
            openversionfile.write("{}\n".format(random_text(1024)))

    find_in_files_asserts(guessing.find_in_files())
Exemple #6
0
def test_find_in_files__ignored_dir(find_in_files_setup):
    """Ensure data is not considered from ignored directories."""

    ignored_dir = os.path.join(find_in_files_setup[0], "other-pkg.egg")
    os.mkdir(ignored_dir)
    with open(os.path.join(ignored_dir, "__init__.py"), "w") as openinit:
        openinit.write("\n".join([
            "__author__ = 'mohammad ali'",
            "__email__ = '*****@*****.**'",
            '__version__ = "2.0.0-beta"',
        ]))

    find_in_files_asserts(guessing.find_in_files())
Exemple #7
0
def test_latest_git_tag(simple_package):
    """If the project is under git control and has tags, return the newest."""

    os.mkdir(".git")
    os.mkdir(os.path.join(".git", "refs"))
    os.mkdir(os.path.join(".git", "refs", "tags"))

    for i in range(2):
        if i:
            time.sleep(1.1)

        name = random_text(6)
        contents = random_text(40)
        with open(os.path.join(".git", "refs", "tags", name), "w") as opentag:
            opentag.write(contents)

    assert guessing.find_in_files()["version"] == name
Exemple #8
0
def test_latest_git_tag(simple_package):
    """If the project is under git control and has tags, return the newest."""

    os.mkdir(".git")
    os.mkdir(os.path.join(".git", "refs"))
    os.mkdir(os.path.join(".git", "refs", "tags"))

    for i in range(2):
        if i:
            time.sleep(1.1)

        name = random_text(6)
        contents = random_text(40)
        with open(os.path.join(".git", "refs", "tags", name), "w") as opentag:
            opentag.write(contents)

    assert guessing.find_in_files()["version"] == name
Exemple #9
0
def test_find_in_files(find_in_files_setup):
    """Write some attribute data to package files and find them."""

    find_in_files_asserts(guessing.find_in_files())
Exemple #10
0
def test_find_in_files(find_in_files_setup):
    """Write some attribute data to package files and find them."""

    find_in_files_asserts(guessing.find_in_files())