Add tests for the filename.

Test that the stacklevel is handled correctly.
diff --git a/Lib/test/test_warnings.py b/Lib/test/test_warnings.py
index 671ed02..f6c9339 100644
--- a/Lib/test/test_warnings.py
+++ b/Lib/test/test_warnings.py
@@ -3,6 +3,8 @@
 import unittest
 from test import test_support
 
+import warning_tests
+
 # The warnings module isn't easily tested, because it relies on module
 # globals to store configuration information.  setUp() and tearDown()
 # preserve the current settings to avoid bashing them while running tests.
@@ -97,6 +99,28 @@
         warnings._setoption('error::Warning::0')
         self.assertRaises(UserWarning, warnings.warn, 'convert to error')
 
+    def test_filename(self):
+        warning_tests.inner("spam1")
+        self.assertEqual(msg.filename, "warning_tests.py")
+        warning_tests.outer("spam2")
+        self.assertEqual(msg.filename, "warning_tests.py")
+
+    def test_stacklevel(self):
+        # Test stacklevel argument
+        # make sure all messages are different, so the warning won't be skipped
+        warning_tests.inner("spam3", stacklevel=1)
+        self.assertEqual(msg.filename, "warning_tests.py")
+        warning_tests.outer("spam4", stacklevel=1)
+        self.assertEqual(msg.filename, "warning_tests.py")
+
+        warning_tests.inner("spam5", stacklevel=2)
+        self.assertEqual(msg.filename, "test_warnings.py")
+        warning_tests.outer("spam6", stacklevel=2)
+        self.assertEqual(msg.filename, "warning_tests.py")
+
+        warning_tests.inner("spam7", stacklevel=9999)
+        self.assertEqual(msg.filename, "sys")
+
 
 def test_main(verbose=None):
     # Obscure hack so that this test passes after reloads or repeated calls