New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
py3: minor cleanup in sage.finance.stock #26213
Comments
Branch: u/chapoton/26213 |
New commits:
|
Commit: |
comment:2
The two tests use the doctest tag |
Reviewer: Vincent Klein |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:5
thanks, fixed |
comment:6
With python3, i get :
And if i add a
It behave as if the Error is not catched by the doctest framework. |
comment:7
Then let us ask for help.. Erik or Jeroen, any idea ? |
comment:8
To simplify i have tested the following doctest :
The first test pass and the second fails. |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:10
ok. So the reason is that there is in sage doctesting framework a mechanism that modifies some subexceptions of OSError in python3, and replace them with OSError. Should be good to go now. Unless Erik (@embray) has a better idea ? |
comment:11
Indeed, it's the #25676 ticket. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
comment:13
It's ok for me. I let Eric pass it in positive review. |
comment:15
Well, I tried and it did not work. Because you are busy on other stuff, I thought it was good enough for the moment. |
comment:16
This is pretty low priority though (I would argue even trivial) so I don't see any reason to rush to a fix. I can have a look at it. |
comment:17
Weird. I don't even have that test locally. Was it just added in 8.4.beta4? |
comment:18
last modified seven years ago.. |
comment:19
Oh I see now. In my branch I just removed that test completely because it was pointless. All it's testing is that the |
comment:20
I have some other minor cleanup in that file as well, such as replacing diff --git a/src/sage/finance/stock.py b/src/sage/finance/stock.py
index 1c9ba47..dfab025 100644
--- a/src/sage/finance/stock.py
+++ b/src/sage/finance/stock.py
@@ -124,7 +124,7 @@ class OHLC:
True
"""
return not (self == other)
-
+
class Stock:
"""
@@ -562,18 +562,11 @@ class Stock:
1212407640 187.75 188.00 187.75 188.00 2000,
1212405780 187.80 187.80 187.80 187.80 100
]
-
- This tests a file that doesn't exist::
-
- sage: finance.Stock("AAPL").load_from_file("I am not a file")
- Traceback (most recent call last):
- ...
- IOError: [Errno 2] No such file or directory: 'I am not a file'
"""
- file_obj = open(file, 'r')
- R = file_obj.read();
+ with open(file, 'r') as fobj:
+ R = fobj.read()
+
self.__historical = self._load_from_csv(R)
- file_obj.close()
return self.__historical Still weird that it's failing for you though. I might temporarily restore the test just to investigate a little. But I still think it should just be deleted entirely. |
comment:21
For that matter the |
comment:22
Ah, I see the problem. There are two classes of exception name mappings surrounding On Python 3 the doctester code treats either one case, or the other. But in this case it should treat both by mapping |
comment:23
ok. Let us remove the useless doctest here. |
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
|
comment:25
done, ready for review again |
comment:27
In case it helps Volker. |
Changed branch from u/chapoton/26213 to |
CC: @embray @jdemeyer
Component: python3
Author: Frédéric Chapoton
Branch/Commit:
d73a9fe
Reviewer: Vincent Klein
Issue created by migration from https://trac.sagemath.org/ticket/26213
The text was updated successfully, but these errors were encountered: