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