Hello community,

here is the log from the commit of package python-pytest-check-links for 
openSUSE:Factory checked in at 2020-05-01 11:09:07
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-pytest-check-links (Old)
 and      /work/SRC/openSUSE:Factory/.python-pytest-check-links.new.2738 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-pytest-check-links"

Fri May  1 11:09:07 2020 rev:4 rq:798142 version:0.3.4

Changes:
--------
--- 
/work/SRC/openSUSE:Factory/python-pytest-check-links/python-pytest-check-links.changes
      2020-04-04 12:26:37.376001820 +0200
+++ 
/work/SRC/openSUSE:Factory/.python-pytest-check-links.new.2738/python-pytest-check-links.changes
    2020-05-01 11:09:28.415341218 +0200
@@ -1,0 +2,6 @@
+Mon Apr 27 10:25:16 UTC 2020 - Tomáš Chvátal <[email protected]>
+
+- Update to 0.3.4:
+  * no changelog
+
+-------------------------------------------------------------------

Old:
----
  pytest_check_links-0.3.2.tar.gz

New:
----
  pytest_check_links-0.3.4.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-pytest-check-links.spec ++++++
--- /var/tmp/diff_new_pack.jcGq2C/_old  2020-05-01 11:09:29.611343818 +0200
+++ /var/tmp/diff_new_pack.jcGq2C/_new  2020-05-01 11:09:29.615343828 +0200
@@ -20,7 +20,7 @@
 # Tests natually require internet
 %bcond_with test
 Name:           python-pytest-check-links
-Version:        0.3.2
+Version:        0.3.4
 Release:        0
 Summary:        Pytest plugin for checking links in files
 License:        BSD-3-Clause

++++++ pytest_check_links-0.3.2.tar.gz -> pytest_check_links-0.3.4.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest_check_links-0.3.2/AUTHORS 
new/pytest_check_links-0.3.4/AUTHORS
--- old/pytest_check_links-0.3.2/AUTHORS        2020-03-30 11:50:04.000000000 
+0200
+++ new/pytest_check_links-0.3.4/AUTHORS        2020-04-21 17:09:34.000000000 
+0200
@@ -1,5 +1,6 @@
 Ian Rose <[email protected]>
 Min RK <[email protected]>
+Nicholas Bollweg <[email protected]>
 Steven Silvester <[email protected]>
 Steven Silvester <[email protected]>
 Vidar Tonaas Fauske <[email protected]>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest_check_links-0.3.2/ChangeLog 
new/pytest_check_links-0.3.4/ChangeLog
--- old/pytest_check_links-0.3.2/ChangeLog      2020-03-30 11:50:04.000000000 
+0200
+++ new/pytest_check_links-0.3.4/ChangeLog      2020-04-21 17:09:34.000000000 
+0200
@@ -1,9 +1,16 @@
 CHANGES
 =======
 
-0.3.2
+0.3.4
 -----
 
+* add checking of self- and local html anchors
+* Add rst to supported files
+* Update metadata for JupyterLab
+
+v0.3.2
+------
+
 * Add note about pbr
 
 0.3.1
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest_check_links-0.3.2/LICENSE 
new/pytest_check_links-0.3.4/LICENSE
--- old/pytest_check_links-0.3.2/LICENSE        2020-03-30 11:40:43.000000000 
+0200
+++ new/pytest_check_links-0.3.4/LICENSE        2020-04-11 23:53:26.000000000 
+0200
@@ -1,4 +1,5 @@
-BSD 3-Clause License
+Copyright (c) 2019 Project Jupyter Contributors
+All rights reserved.
 
 Copyright (c) 2017, Min RK
 All rights reserved.
@@ -6,16 +7,16 @@
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
 
-* Redistributions of source code must retain the above copyright notice, this
-  list of conditions and the following disclaimer.
+1. Redistributions of source code must retain the above copyright notice, this
+   list of conditions and the following disclaimer.
 
-* Redistributions in binary form must reproduce the above copyright notice,
-  this list of conditions and the following disclaimer in the documentation
-  and/or other materials provided with the distribution.
-
-* Neither the name of the copyright holder nor the names of its
-  contributors may be used to endorse or promote products derived from
-  this software without specific prior written permission.
+2. Redistributions in binary form must reproduce the above copyright notice,
+   this list of conditions and the following disclaimer in the documentation
+   and/or other materials provided with the distribution.
+
+3. Neither the name of the copyright holder nor the names of its
+   contributors may be used to endorse or promote products derived from
+   this software without specific prior written permission.
 
 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest_check_links-0.3.2/PKG-INFO 
new/pytest_check_links-0.3.4/PKG-INFO
--- old/pytest_check_links-0.3.2/PKG-INFO       2020-03-30 11:50:04.000000000 
+0200
+++ new/pytest_check_links-0.3.4/PKG-INFO       2020-04-21 17:09:34.000000000 
+0200
@@ -1,10 +1,10 @@
-Metadata-Version: 1.1
+Metadata-Version: 2.1
 Name: pytest_check_links
-Version: 0.3.2
+Version: 0.3.4
 Summary: Check links in files
-Home-page: https://github.com/minrk/pytest-check-links
-Author: Min RK
-Author-email: [email protected]
+Home-page: https://github.com/jupyterlab/pytest-check-links
+Author: Jupyter Development Team
+Author-email: [email protected]
 License: BSD-3-Clause
 Description: # pytest-check-links
         
@@ -13,6 +13,7 @@
         Supported files:
         
         - .html
+        - .rst
         - .md (TODO: select renderer)
         - .ipynb (requires nbconvert)
         
@@ -41,3 +42,4 @@
 Classifier: Operating System :: OS Independent
 Classifier: Programming Language :: Python
 Classifier: Topic :: Software Development :: Testing
+Description-Content-Type: text/markdown
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest_check_links-0.3.2/README.md 
new/pytest_check_links-0.3.4/README.md
--- old/pytest_check_links-0.3.2/README.md      2020-03-30 11:40:43.000000000 
+0200
+++ new/pytest_check_links-0.3.4/README.md      2020-04-11 23:53:54.000000000 
+0200
@@ -5,6 +5,7 @@
 Supported files:
 
 - .html
+- .rst
 - .md (TODO: select renderer)
 - .ipynb (requires nbconvert)
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest_check_links-0.3.2/examples/anchors_other.html 
new/pytest_check_links-0.3.4/examples/anchors_other.html
--- old/pytest_check_links-0.3.2/examples/anchors_other.html    1970-01-01 
01:00:00.000000000 +0100
+++ new/pytest_check_links-0.3.4/examples/anchors_other.html    2020-04-21 
17:04:48.000000000 +0200
@@ -0,0 +1,9 @@
+<!doctype html>
+<html>
+  <head></head>
+  <body>
+    <a href="./anchors_self.html#foo">foo is good</a>
+    <a href="./anchors_self.html#bar">bar is ambiguous</a>
+    <a href="./anchors_self.html#baz">baz is missing</a>
+  </body>
+</html>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest_check_links-0.3.2/examples/anchors_self.html 
new/pytest_check_links-0.3.4/examples/anchors_self.html
--- old/pytest_check_links-0.3.2/examples/anchors_self.html     1970-01-01 
01:00:00.000000000 +0100
+++ new/pytest_check_links-0.3.4/examples/anchors_self.html     2020-04-21 
17:04:48.000000000 +0200
@@ -0,0 +1,13 @@
+<!doctype html>
+<html>
+  <head></head>
+  <body>
+    <a name="foo"></a><h1>FOO</h1>
+    <a name="bar"></a><h2>BAR</h2>
+    <a name="bar"></a><h3>ANOTHER BAR</h3>
+
+    <a href="#foo">foo is good</a>
+    <a href="#bar">bar is ambiguous</a>
+    <a href="#baz">baz is missing</a>
+  </body>
+</html>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/pytest_check_links-0.3.2/pytest_check_links/plugin.py 
new/pytest_check_links-0.3.4/pytest_check_links/plugin.py
--- old/pytest_check_links-0.3.2/pytest_check_links/plugin.py   2020-03-30 
11:40:43.000000000 +0200
+++ new/pytest_check_links-0.3.4/pytest_check_links/plugin.py   2020-04-21 
17:04:48.000000000 +0200
@@ -21,6 +21,8 @@
     group = parser.getgroup("general")
     group.addoption('--check-links', action='store_true',
         help="Check links for validity")
+    group.addoption('--check-anchors', action='store_true',
+        help="Check link anchors for validity")
     group.addoption('--links-ext', action=StoreExtensionsAction,
         default=default_extensions,
         help="Which file extensions to check links for, "
@@ -38,11 +40,15 @@
     config = parent.config
     if config.option.check_links:
         if path.ext.lower() in config.option.links_ext:
-            return CheckLinks(path, parent)
+            return CheckLinks(path, parent, config.option.check_anchors)
 
 
 class CheckLinks(pytest.File):
     """Check the links in a file"""
+    def __init__(self, path, parent, check_anchors):
+        super(CheckLinks, self).__init__(path, parent)
+        self.check_anchors = check_anchors
+
     def _html_from_html(self):
         """Return HTML from an HTML file"""
         with io.open(str(self.fspath), encoding=_ENC) as f:
@@ -119,9 +125,10 @@
         if tag == 'a':
             attr = 'href'
             url = element.get('href', '')
-            if url.startswith('#'):
+            if url.startswith('#') and not parent.check_anchors:
                 # skip internal links
                 continue
+
         elif tag in {'img', 'iframe'}:
             attr = 'src'
         else:
@@ -136,7 +143,7 @@
                 if proto.lower() not in {'http', 'https'}:
                     # ignore non-http links (mailto:, data:, etc.)
                     continue
-            yield LinkItem(name, parent, url)
+            yield LinkItem(name, parent, url, parsed)
 
 
 class LinkItem(pytest.Item):
@@ -146,12 +153,14 @@
 
         name, parent: inherited from pytest.Item
         target (str): The URL or path target for the link
+        parsed (xml.etree.ElementTree.Element): The parsed HTML
         description (str, optional): The description to be used in the report 
header
     """
-    def __init__(self, name, parent, target, description=''):
+    def __init__(self, name, parent, target, parsed, description=''):
         super(LinkItem, self).__init__(name, parent)
         self.target = target
         self.retry_attempts = 0
+        self.parsed = parsed
         self.description = description or '{}: {}'.format(self.fspath, target)
 
     def repr_failure(self, excinfo):
@@ -183,6 +192,20 @@
 
         raise BrokenLinkError(self.target, "%s %s" % (obj.code, obj.reason))
 
+    def handle_anchor(self, parsed, anchor):
+        anchors = parsed.findall('*//a[@name="{}"]'.format(anchor))
+
+        if not anchors:
+            raise BrokenLinkError(self.target, "Missing anchor: %s" % anchor)
+
+        if len(anchors) > 1:
+            raise BrokenLinkError(
+                self.target,
+                "Ambiguous anchor: %d (found %s)" % (
+                    len(anchors), anchor
+                )
+            )
+
     def runtest(self):
         if ':' in self.target:
             # external reference, download
@@ -206,10 +229,16 @@
                 raise BrokenLinkError(self.target, "absolute path link")
             # relative URL
             url = self.target
+            anchor = None
             if '?' in url:
                 url = url.split('?')[0]
             if '#' in url:
-                url = url.split('#')[0]
+                url, anchor = url.split('#')
+
+            if not url and anchor:
+                if self.parent.check_anchors:
+                    self.handle_anchor(self.parsed, anchor)
+                return
 
             url_path = unquote(url).replace('/', os.path.sep)
             dirpath = self.fspath.dirpath()
@@ -219,6 +248,11 @@
                 target_path = dirpath.join(rel_path)
                 if target_path.exists():
                     exists = True
+                    # only check anchors in html for now
+                    if ext == ".html" and anchor and self.parent.check_anchors:
+                        with target_path.open() as fpt:
+                            parsed = html5lib.parse(fpt, 
namespaceHTMLElements=False)
+                            return self.handle_anchor(parsed, anchor)
                     break
             if not exists:
                 target_path = dirpath.join(url_path)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/pytest_check_links-0.3.2/pytest_check_links.egg-info/PKG-INFO 
new/pytest_check_links-0.3.4/pytest_check_links.egg-info/PKG-INFO
--- old/pytest_check_links-0.3.2/pytest_check_links.egg-info/PKG-INFO   
2020-03-30 11:50:04.000000000 +0200
+++ new/pytest_check_links-0.3.4/pytest_check_links.egg-info/PKG-INFO   
2020-04-21 17:09:34.000000000 +0200
@@ -1,10 +1,10 @@
-Metadata-Version: 1.1
+Metadata-Version: 2.1
 Name: pytest-check-links
-Version: 0.3.2
+Version: 0.3.4
 Summary: Check links in files
-Home-page: https://github.com/minrk/pytest-check-links
-Author: Min RK
-Author-email: [email protected]
+Home-page: https://github.com/jupyterlab/pytest-check-links
+Author: Jupyter Development Team
+Author-email: [email protected]
 License: BSD-3-Clause
 Description: # pytest-check-links
         
@@ -13,6 +13,7 @@
         Supported files:
         
         - .html
+        - .rst
         - .md (TODO: select renderer)
         - .ipynb (requires nbconvert)
         
@@ -41,3 +42,4 @@
 Classifier: Operating System :: OS Independent
 Classifier: Programming Language :: Python
 Classifier: Topic :: Software Development :: Testing
+Description-Content-Type: text/markdown
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/pytest_check_links-0.3.2/pytest_check_links.egg-info/SOURCES.txt 
new/pytest_check_links-0.3.4/pytest_check_links.egg-info/SOURCES.txt
--- old/pytest_check_links-0.3.2/pytest_check_links.egg-info/SOURCES.txt        
2020-03-30 11:50:04.000000000 +0200
+++ new/pytest_check_links-0.3.4/pytest_check_links.egg-info/SOURCES.txt        
2020-04-21 17:09:34.000000000 +0200
@@ -7,6 +7,8 @@
 requirements.txt
 setup.cfg
 setup.py
+examples/anchors_other.html
+examples/anchors_self.html
 examples/linkcheck.ipynb
 examples/markdown.md
 examples/rst.rst
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/pytest_check_links-0.3.2/pytest_check_links.egg-info/pbr.json 
new/pytest_check_links-0.3.4/pytest_check_links.egg-info/pbr.json
--- old/pytest_check_links-0.3.2/pytest_check_links.egg-info/pbr.json   
2020-03-30 11:50:04.000000000 +0200
+++ new/pytest_check_links-0.3.4/pytest_check_links.egg-info/pbr.json   
2020-04-21 17:09:34.000000000 +0200
@@ -1 +1 @@
-{"git_version": "9d4396b", "is_release": false}
\ No newline at end of file
+{"git_version": "5d62197", "is_release": false}
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest_check_links-0.3.2/setup.cfg 
new/pytest_check_links-0.3.4/setup.cfg
--- old/pytest_check_links-0.3.2/setup.cfg      2020-03-30 11:50:04.000000000 
+0200
+++ new/pytest_check_links-0.3.4/setup.cfg      2020-04-21 17:09:34.000000000 
+0200
@@ -3,11 +3,12 @@
 
 [metadata]
 name = pytest_check_links
-author = Min RK
-author-email = [email protected]
+author = Jupyter Development Team
+author-email = [email protected]
 summary = Check links in files
 description-file = README.md
-home-page = https://github.com/minrk/pytest-check-links
+long-description-content-type = text/markdown
+home-page = https://github.com/jupyterlab/pytest-check-links
 license = BSD-3-Clause
 classifier = 
        Intended Audience :: Developers
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest_check_links-0.3.2/setup.py 
new/pytest_check_links-0.3.4/setup.py
--- old/pytest_check_links-0.3.2/setup.py       2020-03-30 11:49:31.000000000 
+0200
+++ new/pytest_check_links-0.3.4/setup.py       2020-04-11 23:53:26.000000000 
+0200
@@ -3,7 +3,9 @@
 from setuptools import setup
 
 # This repository uses pbr - Python Build Reasonableness
+# https://docs.openstack.org/pbr/latest/
 # The version is set by the current git tag + describe status.
+# The rest of the config data is in setup.cfg
 setup(
     setup_requires=['pbr>=1.9', 'setuptools>=17.1'],
     pbr=True,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest_check_links-0.3.2/test/test_check_links.py 
new/pytest_check_links-0.3.4/test/test_check_links.py
--- old/pytest_check_links-0.3.2/test/test_check_links.py       2020-03-30 
11:40:43.000000000 +0200
+++ new/pytest_check_links-0.3.4/test/test_check_links.py       2020-04-21 
17:04:48.000000000 +0200
@@ -25,3 +25,14 @@
     testdir.copy_example('markdown.md')
     result = testdir.runpytest("-v", "--check-links", "--links-ext=.md,rst")
     result.assert_outcomes(passed=15, failed=6)
+
+def test_anchors_self(testdir):
+    testdir.copy_example('anchors_self.html')
+    result = testdir.runpytest("-v", "--check-links", "--check-anchors")
+    result.assert_outcomes(passed=1, failed=2)
+
+def test_anchors_other(testdir):
+    testdir.copy_example('anchors_self.html')
+    testdir.copy_example('anchors_other.html')
+    result = testdir.runpytest("-v", "--check-links", "--check-anchors", 
"anchors_other.html")
+    result.assert_outcomes(passed=1, failed=2)


Reply via email to