Skip to content

Commit a0074c8

Browse files
further re-org tests
1 parent 5605030 commit a0074c8

File tree

8 files changed

+41
-55
lines changed

8 files changed

+41
-55
lines changed

tests/conftest.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import pytest
2+
import os as os
3+
import pandas as pd
4+
5+
os.environ['MPLBACKEND'] = 'agg'
6+
7+
print('\npd.__version__ =',pd.__version__ ) # for the record
8+
9+
10+
df = pd.read_csv('examples/data/SPY_20110701_20120630_Bollinger.csv',index_col=0,parse_dates=True)
11+
print('df.shape=' , df.shape )
12+
print('df.head(3)=', df.head(3))
13+
print('df.tail(3)=', df.tail(3))
14+
15+
@pytest.fixture()
16+
def bolldata():
17+
return df

tests/mpftests/test_raise.py

Lines changed: 0 additions & 37 deletions
This file was deleted.

tests/mpftests/test_addplot.py renamed to tests/test_addplot.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,25 @@
11
import os as os
2-
import pandas as pd
32
import mplfinance as mpf
43
import matplotlib.pyplot as plt
54
from matplotlib.testing.compare import compare_images
65

7-
print('pd.__version__ =',pd.__version__ ) # for the record
86
print('mpf.__version__ =',mpf.__version__) # for the record
97
print("plt.rcParams['backend'] =",plt.rcParams['backend']) # for the record
108

119
import subprocess
1210
pwd = subprocess.run(['pwd'], stdout=subprocess.PIPE)
13-
print('pwd.stdout=',pwd.stdout)
14-
15-
df = pd.read_csv('examples/data/SPY_20110701_20120630_Bollinger.csv',index_col=0,parse_dates=True)
16-
print('df.shape=' , df.shape )
17-
print('df.head(3)=', df.head(3))
18-
print('df.tail(3)=', df.tail(3))
11+
print('pwd.stdout=',str(pwd.stdout).strip())
1912

2013
prefix='addplot'
21-
tdir='tests/mpftests/test_images/'
22-
refd='tests/mpftests/reference_images/'
23-
#os.system('rm -f '+tdir+prefix+'*.jpg')
14+
tdir='tests/test_images/'
15+
refd='tests/reference_images/'
2416
os.system('rm -f '+tdir+prefix+'*.png')
2517

2618
IMGCOMP_TOLERANCE = 7.0
2719

28-
# ---- Test 01 -----
20+
def test_addplot01(bolldata):
2921

30-
def test_addplot01():
22+
df = bolldata
3123

3224
fname=prefix+'01.png'
3325
mpf.plot(df,volume=True,savefig=tdir+fname)
@@ -39,9 +31,8 @@ def test_addplot01():
3931
print('result=',result)
4032
assert result is None
4133

42-
# ---- Test 02 -----
43-
44-
def test_addplot02():
34+
def test_addplot02(bolldata):
35+
df = bolldata
4536
fname=prefix+'02.png'
4637
apdict = mpf.make_addplot(df['LowerB'])
4738
mpf.plot(df,volume=True,addplot=apdict,savefig=tdir+fname)

tests/original_flavor/test_original_flavor.py renamed to tests/test_original_flavor.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
def test_original_flavor_e2e_examples():
66
"""Run e2e tests for folder"""
77

8-
os.environ['MPLBACKEND'] = 'agg'
98
os.chdir("examples/original_flavor")
10-
119
exs = glob.glob('*.py')
1210
try:
1311
for ex in exs:

tests/test_raise.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import os as os
2+
import pandas as pd
3+
import mplfinance as mpf
4+
import matplotlib.pyplot as plt
5+
from matplotlib.testing.compare import compare_images
6+
7+
print('pd.__version__ =',pd.__version__ ) # for the record
8+
print('mpf.__version__ =',mpf.__version__) # for the record
9+
print("plt.rcParams['backend'] =",plt.rcParams['backend']) # for the record
10+
11+
import pytest
12+
13+
def test_raise(bolldata):
14+
df = bolldata
15+
apdict = mpf.make_addplot(df['LowerB'])
16+
with pytest.raises(ValueError):
17+
mpf.plot(df,volume='True',addplot=apdict)

0 commit comments

Comments
 (0)