{"action":"created","issue":{"url":"https://api.github.com/repos/xonsh/xonsh/issues/1339","repository_url":"https://api.github.com/repos/xonsh/xonsh","labels_url":"https://api.github.com/repos/xonsh/xonsh/issues/1339/labels{/name}","comments_url":"https://api.github.com/repos/xonsh/xonsh/issues/1339/comments","events_url":"https://api.github.com/repos/xonsh/xonsh/issues/1339/events","html_url":"https://github.com/xonsh/xonsh/pull/1339","id":162276154,"number":1339,"title":"WIP Full Pytest Migration","user":{"login":"laerus","id":6930157,"avatar_url":"https://avatars.githubusercontent.com/u/6930157?v=3","gravatar_id":"","url":"https://api.github.com/users/laerus","html_url":"https://github.com/laerus","followers_url":"https://api.github.com/users/laerus/followers","following_url":"https://api.github.com/users/laerus/following{/other_user}","gists_url":"https://api.github.com/users/laerus/gists{/gist_id}","starred_url":"https://api.github.com/users/laerus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laerus/subscriptions","organizations_url":"https://api.github.com/users/laerus/orgs","repos_url":"https://api.github.com/users/laerus/repos","events_url":"https://api.github.com/users/laerus/events{/privacy}","received_events_url":"https://api.github.com/users/laerus/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/xonsh/xonsh/labels/tests","name":"tests","color":"5319e7"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/xonsh/xonsh/milestones/5","html_url":"https://github.com/xonsh/xonsh/milestones/v0.5","labels_url":"https://api.github.com/repos/xonsh/xonsh/milestones/5/labels","id":1848323,"number":5,"title":"v0.5","description":"","creator":{"login":"scopatz","id":320553,"avatar_url":"https://avatars.githubusercontent.com/u/320553?v=3","gravatar_id":"","url":"https://api.github.com/users/scopatz","html_url":"https://github.com/scopatz","followers_url":"https://api.github.com/users/scopatz/followers","following_url":"https://api.github.com/users/scopatz/following{/other_user}","gists_url":"https://api.github.com/users/scopatz/gists{/gist_id}","starred_url":"https://api.github.com/users/scopatz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scopatz/subscriptions","organizations_url":"https://api.github.com/users/scopatz/orgs","repos_url":"https://api.github.com/users/scopatz/repos","events_url":"https://api.github.com/users/scopatz/events{/privacy}","received_events_url":"https://api.github.com/users/scopatz/received_events","type":"User","site_admin":false},"open_issues":9,"closed_issues":20,"state":"open","created_at":"2016-06-25T15:59:08Z","updated_at":"2016-07-01T15:37:43Z","due_on":"2016-08-03T04:00:00Z","closed_at":null},"comments":24,"created_at":"2016-06-25T11:04:36Z","updated_at":"2016-07-01T16:43:17Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/xonsh/xonsh/pulls/1339","html_url":"https://github.com/xonsh/xonsh/pull/1339","diff_url":"https://github.com/xonsh/xonsh/pull/1339.diff","patch_url":"https://github.com/xonsh/xonsh/pull/1339.patch"},"body":"moving to pytest idioms  (some of these should be added to *testing* section on CONTRIBUTING) \r\n\r\nthe conftest.py has a yield_fixture called `xonsh_builtins` that is a replacement for the old \r\n`mock_xonsh_env` context manager. `xonsh_builtins` sets and yields `builtins`\r\nTo use `xonsh_builtins` in a test we just specify it as an argument to the test, i.e:\r\n```\r\ndef test_one(xonsh_builtins):\r\n     ...\r\n```\r\nthe xonsh builtins get set when the test starts and teared when the test ends.\r\n\r\nnote that there is no need to import that fixture from anywhere, fixtures that exist in conftest.py\r\npytest will pick up and use in all tests.\r\n\r\n`xonsh_builtins` sets `__xonsh_env__` to be an empty dict. if we want to set the `__xonsh_env__` to a different initial value we set it directly from `xonsh_builtins.__xonsh_env__`\r\n```\r\ndef test_one(xonsh_builtins):\r\n    xonsh_env.__xonsh_env__ = ENV_1\r\n    ...\r\n```\r\n\r\nif we want to test for different `__xonsh_env__` values we can use parametrization i.e:\r\n```\r\n@pytest.mark.parametrize('env', [ENV_1, ENV_2])\r\ndef test_one(xonsh_builtins, env):\r\n    xonsh_builtins.__xonsh_env__ = env\r\n    ...\r\n```\r\nthis will run 2 times each time with the respective env setup.\r\n\r\nif we want to set the same  `__xonsh_env__`  for different tests we can create a new fixture (ty @melund ! )\r\ni.e:\r\n```\r\n@pytest.fixture\r\ndef special_env(xonsh_builtins):\r\n     xonsh_builtins.__xonsh_env__['Strombus'] = \"gigas\"\r\n\r\ndef test_1(special_env):\r\n     assert True\r\n\r\ndef test_2(special_env):\r\n     assert True\r\n```\r\n\r\ni have added a TODO.txt to track progress."},"comment":{"url":"https://api.github.com/repos/xonsh/xonsh/issues/comments/229993536","html_url":"https://github.com/xonsh/xonsh/pull/1339#issuecomment-229993536","issue_url":"https://api.github.com/repos/xonsh/xonsh/issues/1339","id":229993536,"user":{"login":"laerus","id":6930157,"avatar_url":"https://avatars.githubusercontent.com/u/6930157?v=3","gravatar_id":"","url":"https://api.github.com/users/laerus","html_url":"https://github.com/laerus","followers_url":"https://api.github.com/users/laerus/followers","following_url":"https://api.github.com/users/laerus/following{/other_user}","gists_url":"https://api.github.com/users/laerus/gists{/gist_id}","starred_url":"https://api.github.com/users/laerus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laerus/subscriptions","organizations_url":"https://api.github.com/users/laerus/orgs","repos_url":"https://api.github.com/users/laerus/repos","events_url":"https://api.github.com/users/laerus/events{/privacy}","received_events_url":"https://api.github.com/users/laerus/received_events","type":"User","site_admin":false},"created_at":"2016-07-01T16:43:17Z","updated_at":"2016-07-01T16:43:17Z","body":"in current master in test_parser.py `nodes_equal` checks for that equality and always return False but the test doesn't complain because `DEBUG_LEVEL = 0`, so this is a bug in the `assert_nodes_equal` which i'm removing.\r\n\r\nyou want to me to put different PR for each file under tests?"}}
{"actor":{"display_login":"laerus"}}