MCPcopy
hub / github.com/plotly/dash / test_r_exports

Function test_r_exports

tests/unit/development/test_r_component_gen.py:20–87  ·  view source on GitHub ↗
(make_r_dir)

Source from the content-addressed store, hash-verified

18
19
20def test_r_exports(make_r_dir):
21 extra_file = dedent(
22 """
23 # normal function syntax
24 my_func <- function(a, b) {
25 c <- a + b
26 nested_func <- function() { stop("no!") }
27 another_to_exclude = function(d) { d * d }
28 another_to_exclude(c)
29 }
30
31 # indented (no reason but we should allow) and using = instead of <-
32 # also braces in comments enclosing it {
33 my_func2 = function() {
34 s <- "unmatched closing brace }"
35 ignore_please <- function() { 1 }
36 }
37 # }
38
39 # real example from dash-table that should exclude FUN
40 df_to_list <- function(df) {
41 if(!(is.data.frame(df)))
42 stop("!")
43 setNames(lapply(split(df, seq(nrow(df))),
44 FUN = function (x) {
45 as.list(x)
46 }), NULL)
47 }
48
49 # single-line compressed
50 util<-function(x){x+1}
51
52 # prefix with . to tell us to ignore
53 .secret <- function() { stop("You can't see me") }
54
55 # . in the middle is OK though
56 not.secret <- function() { 42 }
57 """
58 )
59
60 components = ["Component1", "Component2"]
61 prefix = "pre"
62
63 expected_exports = [prefix + c for c in components] + [
64 "my_func",
65 "my_func2",
66 "df_to_list",
67 "util",
68 "not.secret",
69 ]
70
71 mock_component_file = dedent(
72 """
73 nope <- function() { stop("we don't look in component files") }
74 """
75 )
76
77 with open(os.path.join("R", "preComponent1.R"), "w") as f:

Callers

nothing calls this directly

Calls 1

make_namespace_exportsFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…