Opened 4 years ago

Closed 3 years ago

Last modified 3 years ago

#25473 closed defect (fixed)

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

Reported by: slabbe Owned by:
Priority: major Milestone: sage-8.5
Component: finance Keywords:
Cc: Merged in:
Authors: Sébastien Labbé Reviewers: Frédéric Chapoton
Report Upstream: N/A Work issues:
Branch: 268d9be (Commits, GitHub, GitLab) Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by slelievre)

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:

  • #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

Change History (8)

comment:1 Changed 4 years ago by slabbe

  • Description modified (diff)

comment:2 Changed 3 years ago by slabbe

  • Description modified (diff)

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

Last edited 3 years ago by slabbe (previous) (diff)

comment:3 Changed 3 years ago by slelievre

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

comment:4 Changed 3 years ago by slabbe

  • Authors set to Sébastien Labbé
  • Branch set to u/slabbe/25473
  • Commit set to 268d9be19b683a889726022100d15271659f9760
  • Status changed from new to needs_review

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

comment:5 Changed 3 years ago by chapoton

  • Reviewers set to Frédéric Chapoton
  • Status changed from needs_review to positive_review

ok. I would vote for the complete removal.

comment:6 Changed 3 years ago by chapoton

  • Milestone changed from sage-8.3 to sage-8.5

comment:7 Changed 3 years ago by vbraun

  • Branch changed from u/slabbe/25473 to 268d9be19b683a889726022100d15271659f9760
  • Resolution set to fixed
  • Status changed from positive_review to closed

comment:8 Changed 3 years ago by slelievre

  • Commit 268d9be19b683a889726022100d15271659f9760 deleted
  • Description modified (diff)
Note: See TracTickets for help on using tickets.