sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.47k stars 487 forks source link

20 internet doctests failed in sage/finance/stock.py #25473

Closed seblabbe closed 6 years ago

seblabbe commented 6 years ago

As reported on sage-release 8.3.beta3,

sage -t --optional=sage,internet src/sage/finance/stock.py

gives

Running doctests with ID 2018-05-30-22-48-41-52141b2a.
Using --optional=internet,sage
Doctesting 1 file.
sage -t --warn-long 82.6 src/sage/finance/stock.py
**********************************************************************
File "src/sage/finance/stock.py", line 156, in sage.finance.stock.Stock.__init__
Failed example:
    S        # optional -- internet
Expected:
    IBM (...)
Got:
    <repr(<instance at 0x7f2fcce08680>) failed: URLError: <urlopen error [Errno -2] Name or service not known>>
**********************************************************************
...
**********************************************************************
File "src/sage/finance/stock.py", line 626, in sage.finance.stock.Stock._get_data
Failed example:
    finance.Stock('whatever').history() # optional -- internet
Expected:
    Traceback (most recent call last):
    ...
    RuntimeError: Google reported a wrong request (did you specify a cid?)
Got:
    <BLANKLINE>
    Traceback (most recent call last):
      File "/home/slabbe/GitBox/sage/local/lib/python2.7/site-packages/sage/doctest/forker.py", line 562, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/home/slabbe/GitBox/sage/local/lib/python2.7/site-packages/sage/doctest/forker.py", line 972, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.finance.stock.Stock._get_data[1]>", line 1, in <module>
        finance.Stock('whatever').history() # optional -- internet
      File "/home/slabbe/GitBox/sage/local/lib/python2.7/site-packages/sage/finance/stock.py", line 385, in history
        R = self._get_data('NASDAQ:', startdate, enddate, histperiod)
      File "/home/slabbe/GitBox/sage/local/lib/python2.7/site-packages/sage/finance/stock.py", line 637, in _get_data
        data = urlopen(url).read()
      File "/home/slabbe/GitBox/sage/local/lib/python2.7/urllib2.py", line 154, in urlopen
        return opener.open(url, data, timeout)
      File "/home/slabbe/GitBox/sage/local/lib/python2.7/urllib2.py", line 435, in open
        response = meth(req, response)
      File "/home/slabbe/GitBox/sage/local/lib/python2.7/urllib2.py", line 548, in http_response
        'http', request, response, code, msg, hdrs)
      File "/home/slabbe/GitBox/sage/local/lib/python2.7/urllib2.py", line 473, in error
        return self._call_chain(*args)
      File "/home/slabbe/GitBox/sage/local/lib/python2.7/urllib2.py", line 407, in _call_chain
        result = func(*args)
      File "/home/slabbe/GitBox/sage/local/lib/python2.7/urllib2.py", line 556, in http_error_default
        raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
    HTTPError: HTTP Error 403: Forbidden
**********************************************************************
8 items had failures:
   1 of   3 in sage.finance.stock.Stock.__init__
   1 of   2 in sage.finance.stock.Stock.__repr__
   2 of   3 in sage.finance.stock.Stock._get_data
   4 of   6 in sage.finance.stock.Stock.close
   2 of   3 in sage.finance.stock.Stock.current_price_data
   5 of   6 in sage.finance.stock.Stock.history
   1 of   2 in sage.finance.stock.Stock.market_value
   4 of   6 in sage.finance.stock.Stock.open
    [43 tests, 20 failures, 10.21 s]
----------------------------------------------------------------------
sage -t --warn-long 82.6 src/sage/finance/stock.py  # 20 doctests failed
----------------------------------------------------------------------
Total time for all tests: 10.2 seconds
    cpu time: 0.4 seconds
    cumulative wall time: 10.2 seconds

Full log on framabin against 8.5.beta0.

This ticket marks the tests as "known bug".

Related tickets:

Component: finance

Author: Sébastien Labbé

Branch: 268d9be

Reviewer: Frédéric Chapoton

Issue created by migration from https://trac.sagemath.org/ticket/25473

seblabbe commented 6 years ago

Description changed:

--- 
+++ 
@@ -8,7 +8,6 @@

Running doctests with ID 2018-05-30-22-48-41-52141b2a. -Git branch: 25305 Using --optional=internet,sage Doctesting 1 file. sage -t --warn-long 82.6 src/sage/finance/stock.py

seblabbe commented 6 years ago
comment:2

Updated framabin link to include only failures related to finance/stock.py file

seblabbe commented 6 years ago

Description changed:

--- 
+++ 
@@ -74,4 +74,4 @@
     cumulative wall time: 10.2 seconds

-Full log on framabin +Full log on framabin against 8.5.beta0.

slel commented 6 years ago
comment:3

It seems the "Yahoo! Finance" service which allowed to get csv files was disabled in May 2017. I don't see any replacement.

seblabbe commented 6 years ago
comment:4

The module Stock is completely broken. We could just delete it. For now, I suggest to add the #known bug tag to broken optional internet doctests.

Other motivated people could eventually open another ticket to fix the code or deprecate/delete the code.

Meanwhile, let's stop this file from creating noise when running doctests.


New commits:

268d9be25473: (stock.py) adding known bug tag to broken optional doctests
seblabbe commented 6 years ago

Author: Sébastien Labbé

seblabbe commented 6 years ago

Commit: 268d9be

seblabbe commented 6 years ago

Branch: u/slabbe/25473

fchapoton commented 6 years ago

Reviewer: Frédéric Chapoton

fchapoton commented 6 years ago
comment:5

ok. I would vote for the complete removal.

vbraun commented 6 years ago

Changed branch from u/slabbe/25473 to 268d9be

slel commented 6 years ago

Changed commit from 268d9be to none

slel commented 6 years ago

Description changed:

--- 
+++ 
@@ -75,3 +75,10 @@

Full log on framabin against 8.5.beta0. + +This ticket marks the tests as "known bug". + +Related tickets: + +- #25425: finance.Stock -- obtaining stock prices from Google is completely broken now +- #26754: Remove or replace calls to Yahoo! Finance in sage/finance/stock.py