From b31b0ad06b7fc417829cbbb6dff41ba80b8b61a3 Mon Sep 17 00:00:00 2001 From: slozier Date: Fri, 14 Oct 2016 23:54:14 -0400 Subject: [PATCH] Partial fix for #917 (#1466) * Partial fix for #917 * Put generated DLLs in the temp folder --- .gitignore | 31 ++------------- .../IronPython/Lib/iptest/file_util.py | 23 ++++++++--- .../IronPython/Runtime/PythonContext.cs | 2 +- .../IronPython/Tests/compat/sbs_func_args.py | 2 +- .../Tests/modules/io_related/codecs_test.py | 15 ++++---- .../Tests/modules/io_related/fd_test.py | 4 +- .../Tests/modules/io_related/marshal_test.py | 5 ++- Languages/IronPython/Tests/test_buffer.py | 4 +- Languages/IronPython/Tests/test_class.py | 4 +- Languages/IronPython/Tests/test_cliclass.py | 21 +++++----- Languages/IronPython/Tests/test_file.py | 5 +++ Languages/IronPython/Tests/test_imp.py | 15 ++++++-- Languages/IronPython/Tests/test_importpkg.py | 38 ++++++++++++++++--- Languages/IronPython/Tests/test_ipyc.py | 25 ++++++++---- Languages/IronPython/Tests/test_isinstance.py | 6 +++ .../LanguageBoundTextContentProvider.cs | 9 ++++- 16 files changed, 132 insertions(+), 77 deletions(-) diff --git a/.gitignore b/.gitignore index cd04e8ba16..9eb316e925 100644 --- a/.gitignore +++ b/.gitignore @@ -23,34 +23,11 @@ Solutions/TestResults/ Runtime/Samples/Hosting/Scenarios/bin/ # TODO - testing scripts should not create these files -debug.log External.LCA_RESTRICTED/Languages/IronPython/27/Lib/@test_* -External.LCA_RESTRICTED/Languages/IronPython/27/Lib/lib2to3/Grammar2.9.9.alpha.0.pickle -External.LCA_RESTRICTED/Languages/IronPython/27/Lib/lib2to3/PatternGrammar2.9.9.alpha.0.pickle -Languages/IronPython/Tests/ImportTestDir/ -Languages/IronPython/Tests/InheritanceTypes.dll -Languages/IronPython/Tests/OutterDir/ -Languages/IronPython/Tests/another.py -Languages/IronPython/Tests/cached_type_dll.dll -Languages/IronPython/Tests/cp7007/ -Languages/IronPython/Tests/finaltest.dll -Languages/IronPython/Tests/foo -Languages/IronPython/Tests/imfpstart.tpy -Languages/IronPython/Tests/impcp13736.py -Languages/IronPython/Tests/impmodfrmpkg/ -Languages/IronPython/Tests/onlyread.tmp -Languages/IronPython/Tests/onlywrite.tmp -Languages/IronPython/Tests/tempFile1.tpy -Languages/IronPython/Tests/temp_syspath_none.py -Languages/IronPython/Tests/test.dll -Languages/IronPython/Tests/test.pyil -Languages/IronPython/Tests/test.xaml -Languages/IronPython/Tests/testfile.tmp -Languages/IronPython/Tests/testilcode.dll -Languages/IronPython/Tests/the_dir/ -Languages/IronPython/Tests/tmp* -Languages/IronPython/Tests/tempfile.txt -Languages/IronPython/Tests/vbproptest0.*.dll + +# created by CPython tests +External.LCA_RESTRICTED/Languages/IronPython/27/Lib/lib2to3/Grammar*.pickle +External.LCA_RESTRICTED/Languages/IronPython/27/Lib/lib2to3/PatternGrammar*.pickle # created by side by side tests Languages/IronPython/Tests/compat/*.log diff --git a/Languages/IronPython/IronPython/Lib/iptest/file_util.py b/Languages/IronPython/IronPython/Lib/iptest/file_util.py index 96a3e9635a..6ac9afa5e3 100644 --- a/Languages/IronPython/IronPython/Lib/iptest/file_util.py +++ b/Languages/IronPython/IronPython/Lib/iptest/file_util.py @@ -149,12 +149,17 @@ def filecopy(oldpath, newpath): if of: of.close() if nf: nf.close() -def clean_directory(path): +def clean_directory(path, remove=False): for f in os.listdir(path): try: os.unlink(path_combine(path, f)) except: pass + if remove: + try: + os.rmdir(path) + except: + pass def get_directory_name(file): file = fullpath(file) @@ -198,14 +203,20 @@ def get_mod_names(filename): return ret_val - - -def delete_all_f(module_name): +def delete_all_f(module_name, remove_folders=False): module = sys.modules[module_name] + folders = {} for x in dir(module): if x.startswith('_f_'): fn = getattr(module, x) if isinstance(fn, str): - try: os.unlink(fn) + try: + os.unlink(fn) + name = os.path.dirname(fn) + if os.path.isdir(name): + folders[name] = None except: pass - + if remove_folders: + for x in sorted(folders.iterkeys(), reverse=True): + try: os.rmdir(x) + except: pass diff --git a/Languages/IronPython/IronPython/Runtime/PythonContext.cs b/Languages/IronPython/IronPython/Runtime/PythonContext.cs index 5f357e385f..baf1155df0 100644 --- a/Languages/IronPython/IronPython/Runtime/PythonContext.cs +++ b/Languages/IronPython/IronPython/Runtime/PythonContext.cs @@ -984,7 +984,7 @@ public override ScriptCode CompileSourceCode(SourceUnit/*!*/ sourceUnit, Compile ContractUtils.RequiresNotNull(defaultEncoding, "defaultEncoding"); ContractUtils.Requires(stream.CanSeek && stream.CanRead, "stream", "The stream must support seeking and reading"); - // we choose ASCII by default, if the file has a Unicode pheader though + // we choose ASCII by default, if the file has a Unicode header though // we'll automatically get it as unicode. Encoding encoding = PythonAsciiEncoding.SourceEncoding; diff --git a/Languages/IronPython/Tests/compat/sbs_func_args.py b/Languages/IronPython/Tests/compat/sbs_func_args.py index b250010c0a..3999b933de 100644 --- a/Languages/IronPython/Tests/compat/sbs_func_args.py +++ b/Languages/IronPython/Tests/compat/sbs_func_args.py @@ -24,7 +24,7 @@ def f3(arg0, arg1, arg2, *arg3): return "same## %s %s %s %s" % (arg0, arg1, arg2 from iptest.process_util import run_csc run_csc("/nologo /target:library /out:sbs_library.dll sbs_library.cs") import clr - clr.AddReferenceToFileAndPath("sbs_library.dll") + clr.AddReferenceToFile("sbs_library.dll") from SbsTest import C o = C() g1 = o.M1 diff --git a/Languages/IronPython/Tests/modules/io_related/codecs_test.py b/Languages/IronPython/Tests/modules/io_related/codecs_test.py index e926555de1..bdfa67613d 100644 --- a/Languages/IronPython/Tests/modules/io_related/codecs_test.py +++ b/Languages/IronPython/Tests/modules/io_related/codecs_test.py @@ -505,6 +505,7 @@ def test_file_encodings(): finally: #cleanup sys.path.remove(path_combine(os.getcwd(), "tmp_encodings")) + os.rmdir(path_combine(os.getcwd(), "tmp_encodings")) @skip("silverlight") @skip("netstandard") # sys.executable isn't an executable @@ -548,25 +549,23 @@ def test_file_encodings_negative(): - need variations on the encoding names ''' import sys - if is_posix: - import posix as _os - else: - import nt as _os - sys.path.append(path_combine(_os.getcwd(), "tmp_encodings")) + sys.path.append(path_combine(os.getcwd(), "tmp_encodings")) try: - _os.mkdir(path_combine(_os.getcwd(), "tmp_encodings")) + os.mkdir(path_combine(os.getcwd(), "tmp_encodings")) except: pass try: #negative case - f = open(path_combine(_os.getcwd(), "tmp_encodings", "bad_encoding.py"), "w") + f = open(path_combine(os.getcwd(), "tmp_encodings", "bad_encoding.py"), "w") f.write("# coding: bad") f.close() AssertError(SyntaxError, __import__, "bad_encoding") + os.remove(path_combine(os.getcwd(), "tmp_encodings", "bad_encoding.py")) finally: #cleanup - sys.path.remove(path_combine(_os.getcwd(), "tmp_encodings")) + sys.path.remove(path_combine(os.getcwd(), "tmp_encodings")) + os.rmdir(path_combine(os.getcwd(), "tmp_encodings")) @disabled def test_cp1214(): diff --git a/Languages/IronPython/Tests/modules/io_related/fd_test.py b/Languages/IronPython/Tests/modules/io_related/fd_test.py index b19ac14547..ee5a422265 100644 --- a/Languages/IronPython/Tests/modules/io_related/fd_test.py +++ b/Languages/IronPython/Tests/modules/io_related/fd_test.py @@ -152,7 +152,7 @@ def test_open(): os.close(fd3) os.close(fd4) - for i in range(1, 4): + for i in range(1, 5): os.unlink(test_filename + str(i)) def test_write(): @@ -221,7 +221,7 @@ def test_pipe_fds(): os.close(w) os.close(fd) f.close() - for i in range(1, 2): + for i in range(1, 3): os.unlink(test_filename + str(i)) diff --git a/Languages/IronPython/Tests/modules/io_related/marshal_test.py b/Languages/IronPython/Tests/modules/io_related/marshal_test.py index 4b8adf0349..43e30e1309 100644 --- a/Languages/IronPython/Tests/modules/io_related/marshal_test.py +++ b/Languages/IronPython/Tests/modules/io_related/marshal_test.py @@ -14,7 +14,7 @@ ##################################################################################### from iptest.assert_util import * -if is_silverlight==False: +if not is_silverlight: from iptest.file_util import * import marshal @@ -136,6 +136,9 @@ def test_file_multiple_reads(): obj = marshal.load(f) AreEqual(obj, {i:i}) + f.close() + delete_files('tempfile.txt') + def test_string_interning(): AreEqual(marshal.dumps(['abc', 'abc'], 1), '[\x02\x00\x00\x00t\x03\x00\x00\x00abcR\x00\x00\x00\x00') AreEqual(marshal.dumps(['abc', 'abc']), '[\x02\x00\x00\x00t\x03\x00\x00\x00abcR\x00\x00\x00\x00') diff --git a/Languages/IronPython/Tests/test_buffer.py b/Languages/IronPython/Tests/test_buffer.py index e315a99d31..6f3da99a80 100644 --- a/Languages/IronPython/Tests/test_buffer.py +++ b/Languages/IronPython/Tests/test_buffer.py @@ -172,5 +172,7 @@ def test_write_file(): AssertError(TypeError, f.write, inp) f.close() - + + delete_files('foo') + run_test(__name__) diff --git a/Languages/IronPython/Tests/test_class.py b/Languages/IronPython/Tests/test_class.py index 976c740bbc..594c02bb9b 100644 --- a/Languages/IronPython/Tests/test_class.py +++ b/Languages/IronPython/Tests/test_class.py @@ -134,8 +134,8 @@ def __getattr__(self, name): c.close() try: - import nt - nt.unlink(tmpfile) + import os + os.unlink(tmpfile) except: pass diff --git a/Languages/IronPython/Tests/test_cliclass.py b/Languages/IronPython/Tests/test_cliclass.py index a4c7bde143..d55d27da30 100644 --- a/Languages/IronPython/Tests/test_cliclass.py +++ b/Languages/IronPython/Tests/test_cliclass.py @@ -700,7 +700,7 @@ def test_nondefault_indexers(): """) f.close() - name = 'vbproptest%f.dll' % (r.random()) + name = path_combine(testpath.temporary_dir, 'vbproptest%f.dll' % (r.random())) x = run_vbc('/target:library vbproptest1.vb "/out:%s"' % name) AreEqual(x, 0) @@ -787,7 +787,7 @@ def test_nondefault_indexers_overloaded(): """) f.close() - name = 'vbproptest%f.dll' % (r.random()) + name = path_combine(testpath.temporary_dir, 'vbproptest%f.dll' % (r.random())) AreEqual(run_vbc('/target:library vbproptest1.vb /out:"%s"' % name), 0) clr.AddReferenceToFileAndPath(name) @@ -1534,7 +1534,7 @@ def test_valuetype_iter(): AreEqual(it.next().Key, 'a') AreEqual(it.next().Key, 'b') -@skip("silverlight", "posix", "netstandard") +@skip("silverlight", "posix") def test_abstract_class_no_interface_impl(): # this can't be defined in C# or VB, it's a class which is # abstract and therefore doesn't implement the interface method @@ -1613,13 +1613,15 @@ def test_abstract_class_no_interface_impl(): } // end of class foo """ from iptest.process_util import run_ilasm - f = file('testilcode.il', 'w+') + testilcode = path_combine(testpath.temporary_dir, 'testilcode.il') + + f = file(testilcode, 'w+') f.write(ilcode) f.close() try: - run_ilasm("/dll testilcode.il") + run_ilasm("/dll " + testilcode) - clr.AddReference('testilcode.dll') + clr.AddReferenceToFileAndPath(path_combine(testpath.temporary_dir, 'testilcode.dll')) import AbstractILTest class x(AbstractILTest): @@ -1629,7 +1631,7 @@ def Baz(self): return "42" AreEqual(AbstractILTest.Helper(a), "42") finally: import os - os.unlink('testilcode.il') + os.unlink(testilcode) def test_field_assign(): """assign to an instance field through the type""" @@ -1852,8 +1854,8 @@ class MyXamlRootObject(XamlTestObject): inp.Dispose() finally: - #os.unlink('test.xaml') - pass + import os + os.unlink('test.xaml') @skip("silverlight") @@ -2016,4 +2018,3 @@ def __init__(self, cat, id, qtyOnHand ): #--MAIN------------------------------------------------------------------------ run_test(__name__) - diff --git a/Languages/IronPython/Tests/test_file.py b/Languages/IronPython/Tests/test_file.py index da0392bf08..62c3520a2d 100644 --- a/Languages/IronPython/Tests/test_file.py +++ b/Languages/IronPython/Tests/test_file.py @@ -66,6 +66,9 @@ def test_sanity(): AssertError(ValueError, f.write, "abc") AssertError(ValueError, f.writelines, ["abc","def"]) + os.unlink("onlyread.tmp") + os.unlink("onlywrite.tmp") + ### # The name of a temporary test data file that will be used for the following @@ -613,6 +616,8 @@ def test_newline(norm, mode): test_newline(norm, "r") test_newline(unnorm, "rb") + os.unlink("testfile.tmp") + def test_creation(): f = file.__new__(file, None) Assert(repr(f).startswith("', mode '' at")) diff --git a/Languages/IronPython/Tests/test_imp.py b/Languages/IronPython/Tests/test_imp.py index f5c8a9cdc1..30f1a02eb7 100644 --- a/Languages/IronPython/Tests/test_imp.py +++ b/Languages/IronPython/Tests/test_imp.py @@ -83,6 +83,9 @@ def test_imp_in_exec(): exec 'from System import *' Assert('Int32' in dir()) + delete_files(_f_imfp_start) + clean_directory(path_combine(testpath.public_testdir, _imfp), remove=True) + def test_imp_basic(): magic = imp.get_magic() suffixes = imp.get_suffixes() @@ -92,7 +95,7 @@ def test_imp_basic(): AreEqual(len(suffix), 3) Assert((".py", "U", 1) in suffixes) -if is_silverlight==False: +if not is_silverlight: _testdir = "ImpTest" _imptestdir = path_combine(testpath.public_testdir, _testdir) _f_init = path_combine(_imptestdir, "__init__.py") @@ -358,6 +361,7 @@ def test_sys_path_none_userpy(): finally: sys.path = prevPath + delete_files(path_combine(testpath.public_testdir, "temp_syspath_none.py")) def test_sys_path_none_negative(): @@ -530,7 +534,7 @@ def test_cp7007(): AreEqual(temp_mod.called, 3.14) finally: sys.path.remove(path_combine(testpath.public_testdir, "cp7007")) - delete_files(strange_file_names) + clean_directory(path_combine(testpath.public_testdir, "cp7007"), remove=True) def test_relative_control(): """test various flavors of relative/absolute import and ensure the right @@ -1073,6 +1077,9 @@ def a(self): t = new.classobj('Test1', (getattr(module, 'Test'),), {}) i = t() AreEqual(i.a(), 34) + + moduleInfo[0].close() + delete_files(_f_imp_cp13736) def test_import_path_seperator(): """verify using the path seperator in a direct call will result in an ImportError""" @@ -1354,5 +1361,5 @@ def test_new_builtin_modules(): #------------------------------------------------------------------------------ run_test(__name__) -if is_silverlight==False: - delete_all_f(__name__) +if not is_silverlight: + delete_all_f(__name__, remove_folders=True) diff --git a/Languages/IronPython/Tests/test_importpkg.py b/Languages/IronPython/Tests/test_importpkg.py index a9d8ec2f06..2ee7c91242 100644 --- a/Languages/IronPython/Tests/test_importpkg.py +++ b/Languages/IronPython/Tests/test_importpkg.py @@ -663,6 +663,8 @@ def test_import_inside_exec(): exec 'from another import *' AssertInOrNot(dir(), ['a1', 'a2', 'a3'], ['_a4']) + os.unlink(_f_module) + @skip("silverlight") def test___import___and_packages(): try: @@ -695,6 +697,7 @@ def test___import___and_packages(): os.unlink(_f_init) os.unlink(_f_pkg_y) os.unlink(_f_y) + os.rmdir(_f_dir) @skip("silverlight", "multiple_execute") def test_relative_imports(): @@ -771,9 +774,21 @@ def bar(self): finally: sys.modules = mod_backup os.unlink(_f_init) + os.unlink(_f_pkg_x) os.unlink(_f_pkg_y) os.unlink(_f_subinit) + os.unlink(_f_subpkg_x) os.unlink(_f_subpkg_y) + os.unlink(_f_subpkg_z) + os.unlink(_f_subpkg_a) + os.unlink(_f_subpkg_b) + os.rmdir(_f_subdir) + os.rmdir(_f_dir) + os.unlink(_f_o_init) + os.unlink(_f_temp) + os.unlink(_f_sub_init) + os.rmdir(path_combine(testpath.public_testdir, _d_test, _subdir)) + os.rmdir(path_combine(testpath.public_testdir, _d_test)) @skip("silverlight") def test_import_globals(): @@ -820,6 +835,8 @@ def __getitem__(self, index): os.unlink(_f_x_y) os.unlink(_f_y) os.unlink(_f_test) + os.rmdir(_f_x) + os.rmdir(_f_dir) @skip("silverlight", "multiple_execute") def test_package_back_patching(): @@ -859,10 +876,10 @@ def test_package_back_patching(): if not is_silverlight: #cp3194 try: mod_backup = dict(sys.modules) - _f_module = path_combine(testpath.public_testdir, 'the_test.py') + _f_module2 = path_combine(testpath.public_testdir, 'the_test.py') # write the files - write_to_file(_f_module, '''def foo(some_obj): return 3.14''') + write_to_file(_f_module2, '''def foo(some_obj): return 3.14''') from the_test import * AreEqual(foo(None), 3.14) @@ -874,7 +891,7 @@ class Bar: finally: sys.modules = mod_backup import os - os.unlink(_f_module) + os.unlink(_f_module2) @skip("silverlight", "multiple_execute") @@ -903,6 +920,8 @@ def test_pack_module_relative_collision(): os.unlink(_f_foo_py) os.unlink(_f_foo_init) os.unlink(_f_init) + os.rmdir(_f_foo_dir) + os.rmdir(_f_dir) @skip("silverlight", "multiple_execute") def test_from_import_publishes_in_package(): @@ -924,6 +943,7 @@ def test_from_import_publishes_in_package(): sys.modules = mod_backup os.unlink(_f_foo_py) os.unlink(_f_init) + os.rmdir(_f_dir) @skip("silverlight", "multiple_execute") def test_from_import_publishes_in_package_relative(): @@ -949,6 +969,7 @@ def test_from_import_publishes_in_package_relative(): sys.modules = mod_backup os.unlink(_f_foo_py) os.unlink(_f_init) + os.rmdir(_f_dir) @skip("silverlight", "multiple_execute") def test_from_import_publishes_in_package_relative(): @@ -973,6 +994,7 @@ def test_from_import_publishes_in_package_relative(): sys.modules = mod_backup os.unlink(_f_foo_py) os.unlink(_f_init) + os.rmdir(_f_dir) @skip("silverlight", "multiple_execute") def test_from_import_publishes_in_package_relative_self(): @@ -997,6 +1019,7 @@ def test_from_import_publishes_in_package_relative_self(): sys.modules = mod_backup os.unlink(_f_foo_py) os.unlink(_f_init) + os.rmdir(_f_dir) @skip("silverlight") def test_multiple_relative_imports_and_package(): @@ -1023,6 +1046,7 @@ def test_multiple_relative_imports_and_package(): os.unlink(_f_foo_py) os.unlink(_f_bar_py) os.unlink(_f_init) + os.rmdir(_f_dir) @skip("silverlight") def test_cp34551(): @@ -1058,6 +1082,8 @@ def bar(): os.unlink(_f_foo_py) os.unlink(_f_subinit) os.unlink(_f_init) + os.rmdir(_f_subdir) + os.rmdir(_f_dir) def test_cp35116(): try: @@ -1109,7 +1135,9 @@ def test_cp35116(): os.unlink(_f_pkg2init) os.unlink(_f_pkg1init) os.unlink(_f_init) - + os.rmdir(_f_pkg1) + os.rmdir(_f_pkg2) + os.rmdir(_f_dir) #--MAIN------------------------------------------------------------------------ @@ -1117,4 +1145,4 @@ def test_cp35116(): # remove all test files if not is_silverlight: - delete_all_f(__name__) + delete_all_f(__name__, remove_folders=True) diff --git a/Languages/IronPython/Tests/test_ipyc.py b/Languages/IronPython/Tests/test_ipyc.py index 7aa202fe51..f0c5827355 100644 --- a/Languages/IronPython/Tests/test_ipyc.py +++ b/Languages/IronPython/Tests/test_ipyc.py @@ -399,22 +399,24 @@ def test_compiled_code(): import clr + pyil = os.path.join(testpath.temporary_dir, 'test.pyil') + # make sure we can compile - clr.CompileModules('test.pyil', testpath.public_testdir + '\\test_class.py') + clr.CompileModules(pyil, os.path.join(testpath.public_testdir, 'test_class.py')) # make sure we can compile multiple files - clr.CompileModules('test.pyil', testpath.public_testdir + '\\test_class.py', testpath.public_testdir + '\\test_slice.py') + clr.CompileModules(pyil, os.path.join(testpath.public_testdir, 'test_class.py'), os.path.join(testpath.public_testdir, 'test_slice.py')) - clr.AddReference('test.pyil') + clr.AddReferenceToFileAndPath(pyil) import nt # and make sure we can run some reasonable sophisticated code... - System.IO.File.Move(testpath.public_testdir + '\\test_class.py', 'old_test_class.py') + System.IO.File.Move(os.path.join(testpath.public_testdir, 'test_class.py'), 'old_test_class.py') try: import test_class Assert(test_class.test_oldstyle_getattr.__doc__ != '') finally: - System.IO.File.Move('old_test_class.py', testpath.public_testdir + '\\test_class.py') + System.IO.File.Move('old_test_class.py', os.path.join(testpath.public_testdir, 'test_class.py')) @skip("multiple_execute") @skip("netstandard") # no System.ICloneable in netstandard @@ -422,7 +424,10 @@ def test_cached_types(): import clr from System import IComparable, IFormattable, ICloneable import IronPythonTest - + + cwd = os.getcwd() + os.chdir(testpath.temporary_dir) + # basic sanity test that we can compile... clr.CompileSubclassTypes('test', (object, )) clr.CompileSubclassTypes('test', object) @@ -433,7 +438,7 @@ def test_cached_types(): # build an unlikely existing type and make sure construction gives us # back the correct type. clr.CompileSubclassTypes('cached_type_dll', (object, IComparable[()], IFormattable, ICloneable)) - asm = System.Reflection.Assembly.Load('cached_type_dll') + asm = System.Reflection.Assembly.LoadFrom(os.path.join(testpath.temporary_dir, 'cached_type_dll.dll')) clr.AddReference(asm) class x(object, IComparable[()], IFormattable, ICloneable): @@ -459,7 +464,7 @@ class x(object, IComparable[()], IFormattable, ICloneable): queue.append(attr) clr.CompileSubclassTypes('InheritanceTypes', *types) - clr.AddReference('InheritanceTypes') + clr.AddReferenceToFileAndPath(os.path.join(testpath.temporary_dir, 'InheritanceTypes.dll')) import test_inheritance #http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=21892 @@ -467,4 +472,8 @@ class x(object, IComparable[()], IFormattable, ICloneable): clr.CompileSubclassTypes('finaltest', *clr.GetSubclassedTypes()) clr.AddReference('finaltest') + os.chdir(cwd) + run_test(__name__) + +os.remove('tempFile1.tpy') diff --git a/Languages/IronPython/Tests/test_isinstance.py b/Languages/IronPython/Tests/test_isinstance.py index 98f1b5a54f..b7fc343f23 100644 --- a/Languages/IronPython/Tests/test_isinstance.py +++ b/Languages/IronPython/Tests/test_isinstance.py @@ -66,6 +66,9 @@ def verify_file(ff): AreEqual(ms.GetBuffer()[4], ord('o')) ms.Close() + import os + os.remove("testfile.tmp") + # more tests for 'open' @skip("silverlight") def test_open(): @@ -129,6 +132,9 @@ def test_redirect(): Assert(l == ["1\n", "2\n", "2\n", "3\n", "4\n", "5\n", "6\n", "7\n", "8\n", "9\n", "0\n"]) f.close() + import os + os.remove("testfile.tmp") + def test_conversions(): success=False try: diff --git a/Runtime/Microsoft.Scripting/Runtime/LanguageBoundTextContentProvider.cs b/Runtime/Microsoft.Scripting/Runtime/LanguageBoundTextContentProvider.cs index 3e74128b79..4c140b39e2 100644 --- a/Runtime/Microsoft.Scripting/Runtime/LanguageBoundTextContentProvider.cs +++ b/Runtime/Microsoft.Scripting/Runtime/LanguageBoundTextContentProvider.cs @@ -38,7 +38,14 @@ public LanguageBoundTextContentProvider(LanguageContext context, StreamContentPr } public override SourceCodeReader GetReader() { - return _context.GetSourceReader(_streamProvider.GetStream(), _defaultEncoding, _path); + Stream stream = _streamProvider.GetStream(); + try { + return _context.GetSourceReader(stream, _defaultEncoding, _path); + } + catch { + stream.Dispose(); + throw; + } } } }