Q: why is the reported terminal size off when runn...
# development
c
Q: why is the reported terminal size off when running pytest with Pants? (bug or missing feature?)
Copy code
import shutil
print(shutil.get_terminal_size())
>> os.terminal_size(columns=80, lines=24)
expected:
Copy code
In [2]: shutil.get_terminal_size()
Out[2]: os.terminal_size(columns=245, lines=63)
1
It makes the reports for failed tests using the pytest-icdiff wrap unnecessarily short lines making them harder to read..
like this:
Copy code
>       assert expected == dict(rsp.dependencies_rule)
E       assert equals failed
E         {                                {
E           Address(src/f:internal): Depe    Address(src/f:internal): Depe
E         ndencyRuleAction.ALLOW,          ndencyRuleAction.ALLOW,
E           Address(src/r:r): DependencyR    Address(src/r:r): DependencyR
E         uleAction.ALLOW,                 uleAction.ALLOW,
E           Address(src/r:internal): Depe    Address(src/r:internal): Depe
E         ndencyRuleAction.DENY,           ndencyRuleAction.ALLOW,
E         }                                }
when there’s plenty of space left to the right 😛
oh well, found a workable solution by adding these two little snippets:
Copy code
# .pants.rc
[test]
extra_env_vars.add = [
  "COLUMNS",
  "LINES"
]
and:
Copy code
# .pants.bootstrap
export COLUMNS=`tput cols`
export LINES=`tput lines`
🙌 1
and now I have:
Copy code
>       assert expected == dict(rsp.dependencies_rule)
E       assert equals failed
E         {                                                                                                                   {
E           Address(src/a:internal): DependencyRuleAction.ALLOW,                                                                Address(src/a:internal): DependencyRuleAction.ALLOW,
E           Address(src/a/a2:internal): DependencyRuleAction.DENY,                                                              Address(src/a/a2:internal): DependencyRuleAction.DENY,
E           Address(src/b:b): DependencyRuleAction.ALLOW,                                                                       Address(src/b:b): DependencyRuleAction.WARN,
E           Address(src/b:internal): DependencyRuleAction.DENY,                                                                 Address(src/b:internal): DependencyRuleAction.DENY,
E           Address(src/b/b2:b2): DependencyRuleAction.DENY,                                                                    Address(src/b/b2:b2): DependencyRuleAction.WARN,
E         }                                                                                                                   }

src/python/pants/backend/visibility/rule_types_test.py:344: AssertionError
🙂