2019-06-06 12:18:00 +00:00
|
|
|
use std::fs::File;
|
|
|
|
use std::io;
|
|
|
|
|
2020-06-14 09:27:10 +00:00
|
|
|
use crate::common;
|
2019-08-11 21:51:13 +00:00
|
|
|
|
2020-06-14 09:27:10 +00:00
|
|
|
// TODO - These tests should be moved into the python module when we have sorted out mocking of env
|
|
|
|
// vars.
|
2019-06-06 12:18:00 +00:00
|
|
|
|
2020-04-15 07:55:32 +00:00
|
|
|
#[test]
|
2019-08-11 21:51:13 +00:00
|
|
|
fn with_virtual_env() -> io::Result<()> {
|
2019-10-15 14:01:44 +00:00
|
|
|
let dir = tempfile::tempdir()?;
|
2019-10-15 15:10:16 +00:00
|
|
|
File::create(dir.path().join("main.py"))?.sync_all()?;
|
2019-08-11 21:51:13 +00:00
|
|
|
let output = common::render_module("python")
|
|
|
|
.env("VIRTUAL_ENV", "/foo/bar/my_venv")
|
|
|
|
.arg("--path")
|
|
|
|
.arg(dir.path())
|
|
|
|
.output()?;
|
|
|
|
let actual = String::from_utf8(output.stdout).unwrap();
|
|
|
|
|
2020-06-14 09:27:10 +00:00
|
|
|
assert!(actual.contains("my_venv"));
|
2020-03-15 17:12:25 +00:00
|
|
|
dir.close()
|
2019-08-11 21:51:13 +00:00
|
|
|
}
|
2019-11-02 11:10:21 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn with_active_venv() -> io::Result<()> {
|
|
|
|
let dir = tempfile::tempdir()?;
|
|
|
|
|
|
|
|
let output = common::render_module("python")
|
|
|
|
.env("VIRTUAL_ENV", "/foo/bar/my_venv")
|
|
|
|
.arg("--path")
|
|
|
|
.arg(dir.path())
|
|
|
|
.output()?;
|
|
|
|
let actual = String::from_utf8(output.stdout).unwrap();
|
|
|
|
|
2020-06-14 09:27:10 +00:00
|
|
|
assert!(actual.contains("my_venv"));
|
2020-03-15 17:12:25 +00:00
|
|
|
dir.close()
|
2019-11-02 11:10:21 +00:00
|
|
|
}
|