| 1 |
Description: remove usage of deprecated Nose |
| 2 |
Author: Alexandre Detiste <[email protected]> |
| 3 |
Forwarded: no, project is archived |
| 4 |
|
| 5 |
--- a/influxdb/tests/client_test.py |
| 6 |
+++ b/influxdb/tests/client_test.py |
| 7 |
@@ -32,7 +32,27 @@ |
| 8 |
import requests.exceptions |
| 9 |
import requests_mock |
| 10 |
|
| 11 |
-from nose.tools import raises |
| 12 |
+from functools import wraps |
| 13 |
+ |
| 14 |
+def raises(*exceptions): |
| 15 |
+ valid = ' or '.join([e.__name__ for e in exceptions]) |
| 16 |
+ |
| 17 |
+ def decorate(func): |
| 18 |
+ name = func.__name__ |
| 19 |
+ def newfunc(*arg, **kw): |
| 20 |
+ try: |
| 21 |
+ func(*arg, **kw) |
| 22 |
+ except exceptions: |
| 23 |
+ pass |
| 24 |
+ except: |
| 25 |
+ raise |
| 26 |
+ else: |
| 27 |
+ message = "%s() did not raise %s" % (name, valid) |
| 28 |
+ raise AssertionError(message) |
| 29 |
+ newfunc = wraps(func)(newfunc) |
| 30 |
+ return newfunc |
| 31 |
+ return decorate |
| 32 |
+ |
| 33 |
from urllib3.connection import HTTPConnection |
| 34 |
|
| 35 |
from influxdb import InfluxDBClient |
| 36 |
--- a/influxdb/tests/dataframe_client_test.py |
| 37 |
+++ b/influxdb/tests/dataframe_client_test.py |
| 38 |
@@ -13,7 +13,27 @@ |
| 39 |
import warnings |
| 40 |
import requests_mock |
| 41 |
|
| 42 |
-from nose.tools import raises |
| 43 |
+from functools import wraps |
| 44 |
+ |
| 45 |
+def raises(*exceptions): |
| 46 |
+ valid = ' or '.join([e.__name__ for e in exceptions]) |
| 47 |
+ |
| 48 |
+ def decorate(func): |
| 49 |
+ name = func.__name__ |
| 50 |
+ def newfunc(*arg, **kw): |
| 51 |
+ try: |
| 52 |
+ func(*arg, **kw) |
| 53 |
+ except exceptions: |
| 54 |
+ pass |
| 55 |
+ except: |
| 56 |
+ raise |
| 57 |
+ else: |
| 58 |
+ message = "%s() did not raise %s" % (name, valid) |
| 59 |
+ raise AssertionError(message) |
| 60 |
+ newfunc = wraps(func)(newfunc) |
| 61 |
+ return newfunc |
| 62 |
+ return decorate |
| 63 |
+ |
| 64 |
from influxdb.tests import skip_if_pypy, using_pypy |
| 65 |
|
| 66 |
from .client_test import _mocked_session |
| 67 |
--- a/influxdb/tests/influxdb08/client_test.py |
| 68 |
+++ b/influxdb/tests/influxdb08/client_test.py |
| 69 |
@@ -13,7 +13,27 @@ |
| 70 |
import requests.exceptions |
| 71 |
import requests_mock |
| 72 |
|
| 73 |
-from nose.tools import raises |
| 74 |
+from functools import wraps |
| 75 |
+ |
| 76 |
+def raises(*exceptions): |
| 77 |
+ valid = ' or '.join([e.__name__ for e in exceptions]) |
| 78 |
+ |
| 79 |
+ def decorate(func): |
| 80 |
+ name = func.__name__ |
| 81 |
+ def newfunc(*arg, **kw): |
| 82 |
+ try: |
| 83 |
+ func(*arg, **kw) |
| 84 |
+ except exceptions: |
| 85 |
+ pass |
| 86 |
+ except: |
| 87 |
+ raise |
| 88 |
+ else: |
| 89 |
+ message = "%s() did not raise %s" % (name, valid) |
| 90 |
+ raise AssertionError(message) |
| 91 |
+ newfunc = wraps(func)(newfunc) |
| 92 |
+ return newfunc |
| 93 |
+ return decorate |
| 94 |
+ |
| 95 |
from mock import patch |
| 96 |
|
| 97 |
from influxdb.influxdb08 import InfluxDBClient |
| 98 |
--- a/influxdb/tests/influxdb08/dataframe_client_test.py |
| 99 |
+++ b/influxdb/tests/influxdb08/dataframe_client_test.py |
| 100 |
@@ -10,7 +10,26 @@ |
| 101 |
|
| 102 |
import requests_mock |
| 103 |
|
| 104 |
-from nose.tools import raises |
| 105 |
+from functools import wraps |
| 106 |
+ |
| 107 |
+def raises(*exceptions): |
| 108 |
+ valid = ' or '.join([e.__name__ for e in exceptions]) |
| 109 |
+ |
| 110 |
+ def decorate(func): |
| 111 |
+ name = func.__name__ |
| 112 |
+ def newfunc(*arg, **kw): |
| 113 |
+ try: |
| 114 |
+ func(*arg, **kw) |
| 115 |
+ except exceptions: |
| 116 |
+ pass |
| 117 |
+ except: |
| 118 |
+ raise |
| 119 |
+ else: |
| 120 |
+ message = "%s() did not raise %s" % (name, valid) |
| 121 |
+ raise AssertionError(message) |
| 122 |
+ newfunc = wraps(func)(newfunc) |
| 123 |
+ return newfunc |
| 124 |
+ return decorate |
| 125 |
|
| 126 |
from influxdb.tests import skip_if_pypy, using_pypy |
| 127 |
|