Visitar URL original
test: restore abspath after include-order tests by yangfan-yf-yf · Pull Request #473 · cpplint/cpplint · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
test: restore abspath after include-order tests
  • Loading branch information
yangfan-yf-yf committed Sep 14, 2026
commit 1be454680df8dd9239ee1a7fa4a12c8b4e93df89
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Changelog
TBA
===

* Isolated include-order tests so they no longer affect absolute-path resolution in later tests.
* Fixed a whitespace/newline false positive for control conditions containing lambdas. (#410)
* We now error on relative include paths (``./``, ``../``). (#432)
* This makes ``#include "./foo.h"`` produce two separate errors: that foo.cpp should include foo.h and that relative paths are not allowed.
Expand Down
11 changes: 9 additions & 2 deletions cpplint_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6203,10 +6203,10 @@ def testCollapseStrings(self):

class TestOrderOfIncludes(CpplintTestBase):
@pytest.fixture(autouse=True)
def setUp(self):
def setUp(self, monkeypatch):
CpplintTestBase.setUp(self)
self.include_state = cpplint._IncludeState()
os.path.abspath = lambda value: value
monkeypatch.setattr(os.path, "abspath", lambda value: value)

def testCheckNextIncludeOrder_OtherThenCpp(self):
assert self.include_state.CheckNextIncludeOrder(cpplint._OTHER_HEADER) == ""
Expand Down Expand Up @@ -6488,6 +6488,13 @@ def Format(includes):
)


class TestFileInfo:
def test_full_name_uses_absolute_path(self, tmp_path, monkeypatch):
monkeypatch.chdir(tmp_path)

assert cpplint.FileInfo("source.cc").FullName() == (tmp_path / "source.cc").as_posix()


class TestCheckForFunctionLengths(CpplintTestBase):
@pytest.fixture(autouse=True)
def setUp(self):
Expand Down