Skip to content

Commit 6f9948f

Browse files
Aaron SoellingerAaron Soellinger
authored andcommitted
adding alines test 1
1 parent 85c6589 commit 6f9948f

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

tests/reference_images/alines01.png

35.5 KB
Loading

tests/test_alines.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import os
2+
import os.path
3+
import glob
4+
import mplfinance as mpf
5+
import matplotlib.pyplot as plt
6+
from matplotlib.testing.compare import compare_images
7+
8+
print('mpf.__version__ =',mpf.__version__) # for the record
9+
print("plt.rcParams['backend'] =",plt.rcParams['backend']) # for the record
10+
11+
base='alines'
12+
tdir = os.path.join('tests','test_images')
13+
refd = os.path.join('tests','reference_images')
14+
15+
globpattern = os.path.join(tdir,base+'*.png')
16+
oldtestfiles = glob.glob(globpattern)
17+
18+
for fn in oldtestfiles:
19+
try:
20+
os.remove(fn)
21+
except:
22+
print('Error removing file "'+fn+'"')
23+
24+
IMGCOMP_TOLERANCE = 10.0 # this works fine for linux
25+
# IMGCOMP_TOLERANCE = 11.0 # required for a windows pass. (really 10.25 may do it).
26+
27+
def test_alines01(bolldata):
28+
29+
df = bolldata
30+
31+
fname = base+'01.png'
32+
tname = os.path.join(tdir,fname)
33+
rname = os.path.join(refd,fname)
34+
segments1 = [('2011-09-13', 115.),('2012-02-06', 135.)]
35+
fig_axis = mpf.plot(
36+
df,volume=True,savefig=tname,returnfig=True,alines=segments1
37+
)
38+
39+
plt.close(fig_axis[0])
40+
41+
tsize = os.path.getsize(tname)
42+
print(glob.glob(tname),'[',tsize,'bytes',']')
43+
44+
rsize = os.path.getsize(rname)
45+
print(glob.glob(rname),'[',rsize,'bytes',']')
46+
47+
result = compare_images(rname,tname,tol=IMGCOMP_TOLERANCE)
48+
if result is not None:
49+
print('result=',result)
50+
assert result is None
51+

0 commit comments

Comments
 (0)