File: fix-deprecation

package info (click to toggle)
configobj 5.0.6-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 900 kB
  • sloc: python: 3,034; makefile: 159; sh: 8
file content (47 lines) | stat: -rw-r--r-- 1,561 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
From: Benjamin Drung <benjamin.drung@profitbricks.com>
Date: Thu, 8 Oct 2015 08:44:25 -0700
Subject: Fix deprecation warning test case.

The stacklevel parameter of the warnings.warn function is only required
when wrapper functions are used (to hide the wrapper functions).

The test case needs to be modified to print deprecation warnings (instead
of just ignoring them).
---
 configobj.py            | 2 +-
 tests/test_configobj.py | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/configobj.py b/configobj.py
index ba886e8..7c972a4 100644
--- a/configobj.py
+++ b/configobj.py
@@ -1205,7 +1205,7 @@ class ConfigObj(Section):
             import warnings
             warnings.warn('Passing in an options dictionary to ConfigObj() is '
                           'deprecated. Use **options instead.',
-                          DeprecationWarning, stacklevel=2)
+                          DeprecationWarning)
             
             # TODO: check the values too.
             for entry in options:
diff --git a/tests/test_configobj.py b/tests/test_configobj.py
index 473992b..934d1bf 100644
--- a/tests/test_configobj.py
+++ b/tests/test_configobj.py
@@ -2,6 +2,7 @@
 from __future__ import unicode_literals
 import os
 import re
+import warnings
 
 from codecs import BOM_UTF8
 from warnings import catch_warnings
@@ -107,6 +108,7 @@ def test_order_preserved():
 
 
 def test_options_deprecation():
+    warnings.simplefilter('always', DeprecationWarning)
     with catch_warnings(record=True) as log:
         ConfigObj(options={})