Repository: theacodes/nox (python)

Issue:
Colorized output is not disabled when output is redirected
<!-- Thank you for filing a bug! Please feel free to answer as much or as little of this template as you can. -->

**Describe the bug**
Redirecting nox output does not correctly determine that stdout is not a tty and adds color control codes to the output.

**How to reproduce**
Given a noxfile that defines some targets, e.g. unit tests, run
`cd path/to/repo && python -m nox -s &> output-log.txt`

**Expected behavior**
The contents of `output-log.txt` should be plain ASCII (or UTF-8) and not contain cursor control codes.

Pull request description:
Use stdout.isatty to finalize color
Currently checks stdin
Fixes #266 

Patch:
diff --git a/nox/_options.py b/nox/_options.py
index e8acca6..5ee7343 100644
--- a/nox/_options.py
+++ b/nox/_options.py
@@ -96,7 +96,7 @@ def _color_finalizer(value, args):
     if args.nocolor is True:
         return False
 
-    return sys.stdin.isatty()
+    return sys.stdout.isatty()
 
 
 def _posargs_finalizer(value, args):


Test patch:
diff --git a/tests/test_main.py b/tests/test_main.py
index 715ad31..48df159 100644
--- a/tests/test_main.py
+++ b/tests/test_main.py
@@ -379,7 +379,7 @@ def test_main_color_from_isatty(monkeypatch, isatty_value, expected):
     monkeypatch.setattr(sys, "argv", [sys.executable])
     with mock.patch("nox.workflow.execute") as execute:
         execute.return_value = 0
-        with mock.patch("sys.stdin.isatty") as isatty:
+        with mock.patch("sys.stdout.isatty") as isatty:
             isatty.return_value = isatty_value
 
             # Call the main function.