예제 #1
0
def test_empty_file():

    temp = tempfile.NamedTemporaryFile()
    try:
        contents(temp.name)

        temp.seek(0)
        temp.read().should.be.equal('')
    finally:
        temp.close()
예제 #2
0
def test_unreadable_file():

    temp = tempfile.NamedTemporaryFile(mode="w+b")
    os.chmod(temp.name, 0000)
    try:
        contents(temp.name)

        temp.seek(0)
        temp.read().should.be.equal("")
    finally:
        temp.close()
예제 #3
0
def MakeXML():
    print(zhCN('\r\n\r\n生成采购合同\r\n=====================\r\n'))
    print(zhCN('现在,请将表格中的产品清单复制到剪贴板\r\n\r\n完成后按下回车键继续'))
    my_input()
    mydb = db()
    job = contents(mydb)
    nums = str(job.compile())
    mydb.close_db()
    print(zhCN('\r\n\r\n==================\r\n'))
    print(time.strftime('\r\n\r\n%Y-%m-%d %H:%M:%S  ') + zhCN(nums + '份 合同生成完毕!已经保存在\\out目录下'))
    print_meun()
def test_file_without_levels():

    content = '''/**
 * Project X
 * Author: Jean Pimentel
 * Date: August, 2013
 */

Toc toc! Penny! Toc toc! Penny! Toc toc! Penny!
'''
    temp = tempfile.NamedTemporaryFile()
    try:
        temp.write(content)
        temp.seek(0)

        contents(temp.name)

        temp.seek(0)
        temp.read().should.be.equal(content)
    finally:
        temp.close()
def test_file_with_toc_marker():

    content = '''/**
 * Project X
 * Author: Jean Pimentel
 * Date: August, 2013
 */

/* TABLE OF CONTENTS
============================================================================= */

/* > Intro */
Toc toc! Penny! Toc toc! Penny! Toc toc! Penny!

/* >> The Big Bang Theory << */
The Big Bang Theory is an American sitcom created by Chuck Lorre and Bill Prady.

/* ==>>> Characters ========================================================= */
Leonard Hofstadter, Sheldon Cooper, Howard Wolowitz, Rajesh Koothrappali, Penny

/* >>>> Production
============================================================================= */
Executive producer(s): Chuck Lorre, Bill Prady, Steven Molaro
Producer(s): Faye Oshima Belyeu

/* =>>>>> Info
============================================================================= */
No. of seasons: 5
No. of episodes: 111

/* =>>>>>> Quotes <========================================================== */
* Sheldon: Scissors cuts paper, paper covers rock, rock crushes lizard, lizard poisons Spock, Spock smashes scissors, scissors decapitates lizard, lizard eats paper, paper disproves Spock, Spock vaporizes rock, and as it always has, rock crushes scissors.
* Sheldon: I'm not insane, my mother had me tested!
'''

    new_content = '''/**
 * Project X
 * Author: Jean Pimentel
 * Date: August, 2013
 */

/* TABLE OF CONTENTS

    Intro ............................................................... 18
        The Big Bang Theory ............................................. 21
            Characters .................................................. 24
                Production .............................................. 27
                    Info ................................................ 32
                        Quotes .......................................... 37

============================================================================= */

/* > Intro */
Toc toc! Penny! Toc toc! Penny! Toc toc! Penny!

/* >> The Big Bang Theory << */
The Big Bang Theory is an American sitcom created by Chuck Lorre and Bill Prady.

/* ==>>> Characters ========================================================= */
Leonard Hofstadter, Sheldon Cooper, Howard Wolowitz, Rajesh Koothrappali, Penny

/* >>>> Production
============================================================================= */
Executive producer(s): Chuck Lorre, Bill Prady, Steven Molaro
Producer(s): Faye Oshima Belyeu

/* =>>>>> Info
============================================================================= */
No. of seasons: 5
No. of episodes: 111

/* =>>>>>> Quotes <========================================================== */
* Sheldon: Scissors cuts paper, paper covers rock, rock crushes lizard, lizard poisons Spock, Spock smashes scissors, scissors decapitates lizard, lizard eats paper, paper disproves Spock, Spock vaporizes rock, and as it always has, rock crushes scissors.
* Sheldon: I'm not insane, my mother had me tested!
'''

    temp = tempfile.NamedTemporaryFile()
    try:
        temp.write(content)
        temp.seek(0)

        contents(temp.name)

        temp.seek(0)
        temp.read().should.be.equal(new_content)
    finally:
        temp.close()
예제 #6
0
def test_javascript_with_complete_toc():

    content = '''/**
 * Project X
 * Author: Marcos Moura
 * Date: August, 2013
 * Version: 1.0
 */

/* TABLE OF CONTENTS

    Common Variables .................................................... 25
    Call Plugins ........................................................ 39
        Accordion ....................................................... 42
        Modal ........................................................... 54
        Dropdown ........................................................ 73
    Loading third-party scripts ......................................... 83
        Facebook SDK .................................................... 98
        Twitter SDK .................................................... 101

============================================================================= */

/* ==========================================================================
    Main scripts
   ========================================================================== */

/* > Common Variables
============================================================================= */

var SITEURL  = window.location.protocol + '//' + window.location.host,
    PATHNAME = window.location.pathname,
    stopEvent = function(event) {
        (event.preventDefault) ? event.preventDefault() : event.returnValue = false;

        if(event.stopPropagation) {
            event.stopPropagation();
        }
    };


/* > Call Plugins
   ========================================================================== */

/* ===>> Accordion <<=== */

$('.accordion').accordion({
    wrapContent: '.accordion-item',
    titleElement: '.accordion-title',
    contentElement: '.accordion-content',
    effect: 'show',
    duration: 200,
    hideOthers: false
});


/* ===>> Modal <<=== */

$('.button.alert').modal({
    appendTo: '.container',
    overlayClass: 'alert-overlay',
    closeClass: 'close-alert',
    duration: 400,
    css: {
        width: 400,
        height: 'auto',
        marginTop: 0,
        position: 'fixed',
        top: 100,
        background: '#fff'
    },
    centered: true
});


/* ===>> Dropdown <<=== */

$('.dropdown').dropdown({
    dropdownButton: '.button',
    dropdownContent: '.dropdown-content',
    effect: 'slideDown',
    duration: 200
});


/* > Loading third-party scripts
   ========================================================================== */

(function(doc, script) {
    var js,
        fjs = doc.getElementsByTagName(script)[0],
        frag = doc.createDocumentFragment(),
        add = function(url, id) {
            if (doc.getElementById(id)) {return;}
            js = doc.createElement(script);
            js.src = url;
            id && (js.id = id);
            frag.appendChild( js );
        };

    /* >> Facebook SDK */
    add('//connect.facebook.net/pt_BR/all.js#xfbml=1&status=0', 'facebook-jssdk');

    /* >> Twitter SDK */
    add('//platform.twitter.com/widgets.js');

    fjs.parentNode.insertBefore(frag, fjs);
}(document, 'script'));
'''

    temp = tempfile.NamedTemporaryFile()
    try:
        temp.write(content)
        temp.seek(0)

        contents(temp.name)

        temp.seek(0)
        temp.read().should.be.equal(content)
    finally:
        temp.close()
예제 #7
0
def test_css():

    content = '''/**
 * Project X
 * Author: Jean Pimentel
 * Date: August, 2013
 * Version: 1.0
 */

/* > HTML5 display-role reset for older browsers */
button, input, select, textarea {
    width:auto;
    overflow:visible;
    margin:0;
    font-size:100%;
    vertical-align:baseline;
}

/* >> Buttons */
button,
a.button,
input[type='reset'],
input[type='button'],
input[type='submit'] {
    background-color:#eaeaea;
    border:1px solid #ccc;
    color:#555;
}

/* >>> Buttons (Call to Action) */
.call-to-action {
    text-align:center;
}

.call-to-action a.button {
    font-size:24px;
    padding:15px 35px;
}

/* >>> Buttons (Sizes) */
.small a.button {
    font-size:10px;
    padding:3px 6px;
}

.medium a.button {
    font-size:16px;
    padding:8px 16px;
}
'''

    new_content = '''/* TABLE OF CONTENTS

    HTML5 display-role reset for older browsers ......................... 16
        Buttons ......................................................... 25
            Buttons (Call to Action) .................................... 36
            Buttons (Sizes) ............................................. 46

============================================================================= */
/**
 * Project X
 * Author: Jean Pimentel
 * Date: August, 2013
 * Version: 1.0
 */

/* > HTML5 display-role reset for older browsers */
button, input, select, textarea {
    width:auto;
    overflow:visible;
    margin:0;
    font-size:100%;
    vertical-align:baseline;
}

/* >> Buttons */
button,
a.button,
input[type='reset'],
input[type='button'],
input[type='submit'] {
    background-color:#eaeaea;
    border:1px solid #ccc;
    color:#555;
}

/* >>> Buttons (Call to Action) */
.call-to-action {
    text-align:center;
}

.call-to-action a.button {
    font-size:24px;
    padding:15px 35px;
}

/* >>> Buttons (Sizes) */
.small a.button {
    font-size:10px;
    padding:3px 6px;
}

.medium a.button {
    font-size:16px;
    padding:8px 16px;
}
'''

    temp = tempfile.NamedTemporaryFile()
    try:
        temp.write(content)
        temp.seek(0)

        contents(temp.name)

        temp.seek(0)
        temp.read().should.be.equal(new_content)
    finally:
        temp.close()