Repository: sagemath/sage

Issue:
multiple internet doc-test failing in oeis fields
### Steps To Reproduce

From sage-release thread:
https://groups.google.com/g/sage-release/c/ow2oou9Q2dk/m/WCRtC3AsAQAJ
[Sébastien Labbé] observed some doctest warnings in oeis sequence.
```
sage -t --long --random-seed=115567904994049866192669758187637223396 src/sage/databases/oeis.py
**********************************************************************
File "src/sage/databases/oeis.py", line 321, in sage.databases.oeis.OEIS
Failed example:
    fibo.cross_references()[0]                # optional -- internet
Expected:
    'A039834'
Got:
    'A001622'
**********************************************************************
File "src/sage/databases/oeis.py", line 844, in sage.databases.oeis.OEISSequence.raw_entry
Failed example:
    print(f.raw_entry())                  # optional -- internet
Expected:
    %I A000045 M0692 N0256
    %S A000045 0,1,1,2,3,5,8,13,21,34,55,89,144,...
    %T A000045 10946,17711,28657,46368,...
    ...
Got:
    %I A000045 M0692 N0256 #2112 Aug 26 2023 21:04:04
    %S A000045 0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,
    %T A000045 10946,17711,28657,46368,75025,121393,196418,317811,514229,832040,
    ...
**********************************************************************
File "src/sage/databases/oeis.py", line 902, in sage.databases.oeis.OEISSequence.old_IDs
Failed example:
    f.old_IDs()                           # optional -- internet
Expected:
    ('M0692', 'N0256')
Got:
    ('M0692', 'N0256', '#2112', 'Aug', '26', '2023', '21:04:04')
**********************************************************************
**********************************************************************
File "src/sage/databases/oeis.py", line 1055, in sage.databases.oeis.OEISSequence.natural_object
Failed example:
    av = oeis('A087778'); av              # optional -- internet
Expected:
    A087778: Decimal expansion ... Avogadro...
Got:
    doctest:warning
      File "/home/slabbe/GitBox/sage/src/bin/sage-runtests", line 162, in <module>
        err = DC.run()
      File "/home/slabbe/GitBox/sage/src/sage/doctest/control.py", line 1535, in run
        self.run_doctests()
      File "/home/slabbe/GitBox/sage/src/sage/doctest/control.py", line 1147, in run_doctests
        self.dispatcher.dispatch()
      File "/home/slabbe/GitBox/sage/src/sage/doctest/forker.py", line 2085, in dispatch
        self.parallel_dispatch()
      File "/home/slabbe/GitBox/sage/src/sage/doctest/forker.py", line 1980, in parallel_dispatch
        w.start()  # This might take some time
      File "/home/slabbe/GitBox/sage/src/sage/doctest/forker.py", line 2254, in start
        super().start()
      File "/home/slabbe/GitBox/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/multiprocessing/process.py", line 121, in start
        self._popen = self._Popen(self)
      File "/home/slabbe/GitBox/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/multiprocessing/context.py", line 224, in _Popen
        return _default_context.get_context().Process._Popen(process_obj)
      File "/home/slabbe/GitBox/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/multiprocessing/context.py", line 281, in _Popen
        return Popen(process_obj)
      File "/home/slabbe/GitBox/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/multiprocessing/popen_fork.py", line 19, in __init__
        self._launch(process_obj)
      File "/home/slabbe/GitBox/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/multiprocessing/popen_fork.py", line 71, in _launch
        code = process_obj._bootstrap(parent_sentinel=child_r)
      File "/home/slabbe/GitBox/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap
        self.run()
      File "/home/slabbe/GitBox/sage/src/sage/doctest/forker.py", line 2226, in run
        task(self.options, self.outtmpfile, msgpipe, self.result_queue)
      File "/home/slabbe/GitBox/sage/src/sage/doctest/forker.py", line 2556, in __call__
        doctests, extras = self._run(runner, options, results)
      File "/home/slabbe/GitBox/sage/src/sage/doctest/forker.py", line 2608, in _run
        result = runner.run(test)
      File "/home/slabbe/GitBox/sage/src/sage/doctest/forker.py", line 908, in run
        return self._run(test, compileflags, out)
      File "/home/slabbe/GitBox/sage/src/sage/doctest/forker.py", line 709, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/home/slabbe/GitBox/sage/src/sage/doctest/forker.py", line 1144, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.databases.oeis.OEISSequence.natural_object[9]>", line 1, in <module>
        av = oeis('A087778'); av              # optional -- internet
      File "/home/slabbe/GitBox/sage/src/sage/repl/rich_output/display_manager.py", line 831, in displayhook
        plain_text, rich_output = self._rich_output_formatter(obj, dict())
      File "/home/slabbe/GitBox/sage/src/sage/repl/rich_output/display_manager.py", line 654, in _rich_output_formatter
        plain_text = self._backend.plain_text_formatter(obj, **rich_repr_kwds)
      File "/home/slabbe/GitBox/sage/src/sage/repl/rich_output/backend_base.py", line 328, in plain_text_formatter
        plain_text = self._apply_pretty_printer(SagePrettyPrinter, obj)
      File "/home/slabbe/GitBox/sage/src/sage/repl/rich_output/backend_base.py", line 273, in _apply_pretty_printer
        printer.pretty(obj)
      File "/home/slabbe/GitBox/sage/src/sage/repl/display/pretty_print.py", line 144, in pretty
        ok = representation(obj, self, cycle)
      File "/home/slabbe/GitBox/sage/src/sage/repl/display/fancy_repr.py", line 273, in __call__
        output = repr(obj)
      File "/home/slabbe/GitBox/sage/src/sage/databases/oeis.py", line 1312, in _repr_
        return "%s: %s" % ([self.id](http://self.id/)(), [self.name](http://self.name/)())
      File "/home/slabbe/GitBox/sage/src/sage/databases/oeis.py", line 884, in name
        return self._field('N')[0]
      File "/home/slabbe/GitBox/sage/src/sage/databases/oeis.py", line 754, in _field
        self.is_dead(warn_only=True)
      File "/home/slabbe/GitBox/sage/src/sage/databases/oeis.py", line 1153, in is_dead
        warn('This sequence is dead: "{}: {}"'.format([self.id](http://self.id/)(), [self.name](http://self.name/)()), RuntimeWarning)
      File "/home/slabbe/GitBox/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/warnings.py", line 109, in _showwarnmsg
        sw(msg.message, msg.category, msg.filename, msg.lineno,
    :
    RuntimeWarning: This sequence is dead: "A087778: Decimal expansion of experimental Avogadro's constant (in mol^(-1))."
    A087778: Decimal expansion of experimental Avogadro's constant (in mol^(-1)).
**********************************************************************
File "src/sage/databases/oeis.py", line 1058, in sage.databases.oeis.OEISSequence.natural_object
Failed example:
    av.natural_object()                   # optional -- internet
Expected:
    6.022141000000000?e23
Got:
    [6, 0, 2, 2, 1, 4, 1]
**********************************************************************
File "src/sage/databases/oeis.py", line 1795, in sage.databases.oeis.OEISSequence.show
Failed example:
    s.show()                              # optional -- internet
Expected:
    ID
    A012345
    <BLANKLINE>
    NAME
    Coefficients in the expansion sinh(arcsin(x)*arcsin(x)) = 2*x^2/2!+8*x^4/4!+248*x^6/6!+11328*x^8/8!+...
    <BLANKLINE>
    FIRST TERMS
    (2, 8, 248, 11328, 849312, 94857600, 14819214720, 3091936512000, 831657655349760, 280473756197529600, 115967597965430077440, 57712257892456911912960, 34039765801079493369569280)
    <BLANKLINE>
    LINKS
    0: https://oeis.org/A012345/b012345.txt
    <BLANKLINE>
    FORMULAS
    ...
    OFFSETS
    (0, 1)
    <BLANKLINE>
    URL
    https://oeis.org/A012345
    <BLANKLINE>
    AUTHOR
    Patrick Demichel (patrick.demichel(AT)[hp.com](http://hp.com/))
    <BLANKLINE>
Got:
    ID
    A012345
    <BLANKLINE>
    NAME
    Coefficients in the expansion sinh(arcsin(x)*arcsin(x)) = 2*x^2/2!+8*x^4/4!+248*x^6/6!+11328*x^8/8!+...
    <BLANKLINE>
    FIRST TERMS
    (2, 8, 248, 11328, 849312, 94857600, 14819214720, 3091936512000, 831657655349760, 280473756197529600, 115967597965430077440, 57712257892456911912960, 34039765801079493369569280)
    <BLANKLINE>
    LINKS
    0: https://oeis.org/A012345/b012345.txt
    <BLANKLINE>
    FORMULAS
    0: a(n) ~ sqrt(Pi) * cosh(Pi^2/4) * (2*n)! / (2 * n^(3/2)). - _Vaclav Kotesovec_, Feb 08 2015
    <BLANKLINE>
    EXAMPLES
    0: sinh(arcsin(x)*arcsin(x)) = 2*x^2/2! + 8*x^4/4! + 248*x^6/6! + 11328*x^8/8! + ...
    <BLANKLINE>
    PROGRAMS
    [('mathematica', 0: nn = 20; Table[(CoefficientList[Series[Sinh[ArcSin[x]^2], {x, 0, 2*nn}], x] * Range[0, 2*nn]!)[[n]], {n, 1, 2*nn+1, 2}] (* _Vaclav Kotesovec_, Feb 08 2015 *)), ('pari', 0: x='x+O('x^50); v=Vec(serlaplace(sinh(asin(x)*asin(x)))); vector(#v\2,n,v[2*n-1]) \\ _G. C. Greubel_, Apr 11 2017)]
    <BLANKLINE>
    KEYWORDS
    ('nonn',)
    <BLANKLINE>
    OFFSETS
    (0, 1)
    <BLANKLINE>
    URL
    https://oeis.org/A012345
    <BLANKLINE>
    OLD IDS
    ('#16', 'Apr', '12', '2017', '23:19:39')
    <BLANKLINE>
    AUTHOR
    Patrick Demichel (patrick.demichel(AT)[hp.com](http://hp.com/))
    <BLANKLINE>
**********************************************************************
```

### Expected Behavior

All tests passes

### Actual Behavior

5 failing doctests

### Additional Information

The `%I` field is shipped with date and time, which is causing the problem in the doc-test.

### Environment

```markdown
- **OS**: Ubuntu 18.04
```


### Checklist

- [X] I have searched the existing issues for a bug report that matches the one I want to file, without success.
- [X] I have read the documentation and troubleshoot guide


Discussion:

Resolving patch:
diff --git a/src/sage/databases/oeis.py b/src/sage/databases/oeis.py
--- a/src/sage/databases/oeis.py
+++ b/src/sage/databases/oeis.py
@@ -177,7 +177,7 @@ def _fetch(url):
 
     TESTS::
 
-        sage: from sage.databases.oeis import _fetch, oeis_url
+        sage: from sage.databases.oeis import _fetch, oeis_url  # optional -- internet
         sage: _fetch(oeis_url + 'hints.html')[-8:-1]            # optional -- internet
         '</html>'
     """
@@ -309,12 +309,12 @@ class OEIS:
         14930352, 24157817, 39088169, 63245986, 102334155)
 
         sage: fibo.cross_references()[0]                # optional -- internet
-        'A039834'
+        'A001622'
 
         sage: fibo == oeis(45)                          # optional -- internet
         True
 
-        sage: sfibo = oeis('A039834')
+        sage: sfibo = oeis('A039834')                   # optional -- internet
         sage: sfibo.first_terms()                       # optional -- internet
         (1, 1, 0, 1, -1, 2, -3, 5, -8, 13, -21, 34, -55, 89, -144, 233,
         -377, 610, -987, 1597, -2584, 4181, -6765, 10946, -17711, 28657,
@@ -707,11 +707,12 @@ def online_update(self):
 
         TESTS::
 
+            sage: # optional -- internet
             sage: s = oeis._imaginary_sequence(ident='A004238')
             sage: s
             A004238: The characteristic sequence of 42 plus one, starting from 38.
-            sage: s.online_update()                     # optional -- internet
-            sage: s                                     # optional -- internet
+            sage: s.online_update()
+            sage: s
             A004238: a(n) = 100*log(n) rounded to nearest integer.
         """
         options = {'q': self._id, 'n': '1', 'fmt': 'text'}
@@ -832,7 +833,7 @@ def raw_entry(self):
             A000045: Fibonacci numbers: F(n) = F(n-1) + F(n-2) with F(0) = 0 and F(1) = 1.
 
             sage: print(f.raw_entry())                  # optional -- internet
-            %I A000045 M0692 N0256
+            %I A000045 M0692 N0256...
             %S A000045 0,1,1,2,3,5,8,13,21,34,55,89,144,...
             %T A000045 10946,17711,28657,46368,...
             ...
@@ -898,7 +899,12 @@ def old_IDs(self):
             sage: s.old_IDs()
             ('M9999', 'N9999')
         """
-        return tuple(self._field('I')[0].split(' '))
+        s = self._field('I')[0]
+        # We remove all parts after '#'
+        s = s.split('#')[0].strip()
+        if not s:
+            return ()
+        return tuple(s.split(' '))
 
     def offsets(self):
         r"""
@@ -1042,11 +1048,11 @@ def natural_object(self):
 
         ::
 
-            sage: av = oeis('A087778'); av              # optional -- internet
-            A087778: Decimal expansion ... Avogadro...
+            sage: av = oeis('A322578'); av              # optional -- internet
+            A322578: Decimal expansion ... Avogadro...
 
             sage: av.natural_object()                   # optional -- internet
-            6.022141000000000?e23
+            6.022140760000000?e23
 
         ::
 
@@ -1111,7 +1117,7 @@ def is_dead(self, warn_only=False):
         A warning is triggered if any field of a dead sequence is accessed,
         unless :meth:`is_dead` is called before::
 
-            sage: s = oeis(17)
+            sage: s = oeis(17)                      # optional -- internet
             sage: s                                 # optional -- internet
             doctest:warning
             ...


Test patch: