testfiles.py :  » Language-Interface » VB-to-Python-Converter » vb2py-0.2 » test » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Language Interface » VB to Python Converter 
VB to Python Converter » vb2py 0.2 » test » testfiles.py
# Created by Leo from: C:\Development\Python22\Lib\site-packages\vb2py\vb2py.leo

from unittest import *
from testframework import *

import vb2py.utils
PATH = vb2py.utils.rootPath()

# << File tests >> (1 of 5)
#  It is hard to test opening and closing files without reading so we do 
#  things all at once

# Open with Input
tests.append((r"""
Open "%s" For Input As #3
Input #3, a
Input #3, b
Input #3, c, d, e
Input #3, f, g
Close #3
""" % vb2py.utils.relativePath("test\\testread.txt"), {'a' : 'Can you hear me now?',
    'b' : 'Can you still hear me now?',
    'c' : 10, 'd' : 20, 'e' : 30,
    'f' : 5, 'g' : "hello",
}))

# Open with Line Input
tests.append((r"""
Open "%s\\test\\testread.txt" For Input As #3
Line Input #3, a
Line Input #3, b
Line Input #3, c
Line Input #3, d
Close #3
""" % PATH, {'a' : 'Can you hear me now?',
    'b' : 'Can you still hear me now?',
    'c' : '10, 20, 30',
    'd' : '5, "hello"',
}))


# Open and using Input() to get numbers of characters
tests.append((r"""
Open "%s\\test\\testread.txt" For Input As #3
a = Input(3, #3)
b = Input(1, #3)
c = Input(3, #3)
Close #3
""" % PATH, {'a' : 'Can',
    'b' : ' ',
    'c' : 'you',
}))
# << File tests >> (2 of 5)
#  It is hard to test opening and closing files without reading so we do 
#  things all at once

# Open with print
tests.append((r"""
Open "%s/test/testwrite.txt" For Output As #3
Print #3, 10
Print #3, 20, 30
Print #3, 40, 50
Print #3, "hello"
Close #3
Open "%s/test/testwrite.txt" For Input As #3
Input #3, a, b, c, d, f
Line Input #3, e
""" % (PATH, PATH), {'a' : 10, 'b' : 20,
    'c' : 30, 'd' : 40, 'e' : 'hello',
    'f' : 50,
}))


# Open with print but no cr
tests.append((r"""
Open "%s/test/testwrite.txt" For Output As #3
Print #3, 10;
Print #3, 20, 30;
Print #3, 40, "hello", 50;
Close #3
Open "%s/test/testwrite.txt" For Input As #3
Line Input #3, a
""" % (PATH, PATH), {'a' : "1020\t3040\thello\t50"}
))
# << File tests >> (3 of 5)
#  Open a couple of files and then use a bare close to close them and check we
#  close ok

# Open with Input
tests.append((r"""
Open "%s" For Input As #3
Open "%s" For Output As #4
Close
Input #3, a
""" % (vb2py.utils.relativePath("test\\testread.txt"), 
     vb2py.utils.relativePath("test\\testwrite.txt")),
{'FAIL' : 'yes',
}))
# << File tests >> (4 of 5)
#  Seek in a file

# Seek as a way of moving around in a file
tests.append((r"""
Open "%s" For Input As #3
Input #3, a
Seek #3, 1
Input #3, b
Seek #3, 5
Input #3, c
""" % vb2py.utils.relativePath("test\\testread.txt"),
{
'a' : 'Can you hear me now?',
'b' : 'Can you hear me now?',
'c' : 'you hear me now?',
}))


# Seek as a property of the file
tests.append((r"""
Open "%s" For Input As #3
a = Seek(3)
Input #3, _a
b = Seek(3)
Seek #3, 5
c = Seek(3)
""" % vb2py.utils.relativePath("test\\testread.txt"),
{
'a' : 1,
'b' : 23,
'c' : 5,
}))
# << File tests >> (5 of 5)
#  Return the directory of file matches - this is a weird function

# Dir
tests.append((r"""
a = Dir("test\\test*.txt")
b = Dir()
c = Dir()
""",
{
'a' : 'testread.txt',
'b' : 'testwrite.txt',
'c' : '',
}))


# Dir$
tests.append((r"""
a = Dir$("test\\test*.txt")
b = Dir$()
c = Dir$()
""",
{
'a' : 'testread.txt',
'b' : 'testwrite.txt',
'c' : '',
}))

# Dir no parenthesis
tests.append((r"""
a = Dir("test\\test*.txt")
b = Dir
c = Dir
""",
{
'a' : 'testread.txt',
'b' : 'testwrite.txt',
'c' : '',
}))

# Dir$ no parenthesis
tests.append((r"""
a = Dir$("test\\test*.txt")
b = Dir$
c = Dir$
""",
{
'a' : 'testread.txt',
'b' : 'testwrite.txt',
'c' : '',
}))
# -- end -- << File tests >>


import vb2py.vbparser
vb2py.vbparser.log.setLevel(0) # Don't print all logging stuff
TestClass = addTestsTo(BasicTest, tests)


if __name__ == "__main__":
  main()
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.