~ubuntu-branches/ubuntu/maverick/python3.1/maverick

« back to all changes in this revision

Viewing changes to Lib/test/test_startfile.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2009-03-23 00:01:27 UTC
  • Revision ID: james.westby@ubuntu.com-20090323000127-5fstfxju4ufrhthq
Tags: upstream-3.1~a1+20090322
ImportĀ upstreamĀ versionĀ 3.1~a1+20090322

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Ridiculously simple test of the os.startfile function for Windows.
 
2
#
 
3
# empty.vbs is an empty file (except for a comment), which does
 
4
# nothing when run with cscript or wscript.
 
5
#
 
6
# A possible improvement would be to have empty.vbs do something that
 
7
# we can detect here, to make sure that not only the os.startfile()
 
8
# call succeeded, but also the the script actually has run.
 
9
 
 
10
import unittest
 
11
from test import support
 
12
 
 
13
# use this form so that the test is skipped when startfile is not available:
 
14
from os import startfile, path
 
15
 
 
16
class TestCase(unittest.TestCase):
 
17
    def test_nonexisting(self):
 
18
        self.assertRaises(OSError, startfile, "nonexisting.vbs")
 
19
 
 
20
    def test_empty(self):
 
21
        empty = path.join(path.dirname(__file__), "empty.vbs")
 
22
        startfile(empty)
 
23
        startfile(empty, "open")
 
24
 
 
25
def test_main():
 
26
    support.run_unittest(TestCase)
 
27
 
 
28
if __name__=="__main__":
 
29
    test_main()