Пример #1
0
def test_capitalize():
    """ test an actual string """
    capital_mod.capitalize("sample_text_file.txt", "sample_text_file_cap.txt")
    contents = open("sample_text_file_cap.txt", 'U').read()
    expected = """This Is A Really Simple Text File.
It Is Here So That I Can Test The Capitalize Script.

And That's Only There To Try Out Distutils.

So There."""
    assert contents.strip() == expected 
def test_capitalize(test_file_path):
    """ test an actual file """
    p = test_file_path

    new_file_path = (p.parent / (p.stem + "_cap")).with_suffix(p.suffix)

    capital_mod.capitalize(p, new_file_path)

    contents = open(new_file_path).read()
    expected = """This is a Really Simple Text File.
It is Here So That I Can Test the Capitalize Script.

And That's Only There to Try Out Packaging.

So There."""
    assert contents.strip() == expected 
def test_capitalize(test_textfile):
    """ test an actual file """
    # capitalize the file
    capital_mod.capitalize(test_textfile, "sample_text_file_cap.txt")

    # now check it
    with open("sample_text_file_cap.txt", 'U') as infile:
        contents = infile.read()

    expected = """This Is A Really Simple Text File.
It Is Here So That I Can Test The Capitalize Script.

And That's Only There To Try Out Packaging And Documentation.

So There."""

    assert contents.strip() == expected
Пример #4
0
def test_capitalize(test_textfile):
    """ test an actual file """
    # capitalize the file
    capital_mod.capitalize(test_textfile, "sample_text_file_cap.txt")

    # now check it
    with open("sample_text_file_cap.txt", 'U') as infile:
        contents = infile.read()

    expected = """This Is A Really Simple Text File.
It Is Here So That I Can Test The Capitalize Script.

And That's Only There To Try Out Packaging And Documentation.

So There."""

    assert contents.strip() == expected
Пример #5
0
def main():
    """
    startup function for running a capitalize as a script
    """
    try:
        infilename = sys.argv[1]
    except IndexError:
        print("you need to pass in a file name to process")
        print(help)
        sys.exit()
    try:
        outfilename = sys.argv[2]
    except IndexError:
        root, ext = os.path.splitext(infilename)
        outfilename = root + "_cap" + ext

    # do the real work:
    print("Capitalizing: %s and storing it in %s" % (infilename, outfilename))

    capital_mod.capitalize(infilename, outfilename)

    print("I'm done")
Пример #6
0
#!/usr/bin/env python
"""
A really simple script just to demonstrate disutils
"""

import sys
import os
from capitalize import capital_mod

if __name__ == "__main__":
    try:
        infilename = sys.argv[1]
    except IndexError:
        print("you need to pass in a file to process")

    root, ext = os.path.splitext(infilename)
    outfilename = root + "_cap" + ext

    # do the real work:
    print("Capitalizing: %s and storing it in %s" % (infilename, outfilename))
    capital_mod.capitalize(infilename, outfilename)

    print("I'm done")
Пример #7
0
#!/usr/bin/env python

"""
A really simple script just to demonstrate disutils
"""

import sys, os
from capitalize import capital_mod


if __name__ == "__main__":
    try:
        infilename = sys.argv[1]
    except IndexError:
        print "you need to pass in a file to process"

    root, ext = os.path.splitext(infilename)
    outfilename = root + "_cap" + ext

    # do the real work:
    print "Capitalizing: %s and storing it in %s"%(infilename, outfilename)
    capital_mod.capitalize(infilename, outfilename)

    print "I'm done"